Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you set up an icon in an awt frame?

Status
Not open for further replies.

fla5h

Programmer
Oct 24, 1999
3
0
0
GB
Visit site
I would like to use an icon in my awt frame but Frame.setIconImage() wants an Image class.  How do I get my icon into an instance of Image?
 
well the class ImageIcon, which implements Icon, can take an Image object as its constructor.<br><br>If you have an ImageIcon, and you want an Image, invoke the method getImage() .. Hope that helps. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
<A HREF=" TARGET="_new"> did this on my latest project, it looks pretty neat code:<br><br>class Proj6Frame extends JFrame<br>{<br>setTitle(&quot;Project6 by Tom Moses&quot;);<br><br>//this allows you to import a new image and it links it to the icon<br>//image<br>Image img = tk.getImage(&quot;cursor.gif&quot;);<br>setIconImage(img);<br><br>//setting a custom cursor needs to set the try catch so if the image is not their <br>//the mouse will still appear<br><br>setCursor(tk.createCustomCursor(img,new Point(0,3),&quot;Starcraft&quot;));<br>}<br><br>in the JFrame class you can call these functions, good luck<br><br> <p>moses<br><a href=mailto:tmoses@iname.com>tmoses@iname.com</a><br><a href= my site</a><br>"In the beginning there was HTML, and it was good"<br>
by Nick Heinle, Designing with JavaScript<br>
<br>
<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top