Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to change the icon on the top left side?  RSS feed

 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am newbie of swing programming. Every java standalone programming, the icon at the top left hand corner must be a coffee icon. Can anyone tell me how to change that icon?


Thanks
Benson
 
otnip otnip
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using a JFrame - you can use setIconImage. If you are using Java 1.6, you can go even further and use setIconImages - but for now - try the first.

JFrame frame = new JFrame();
Image image = ImageIO.read(new File("xxx"));
frame.setIconImage(image);
frame.setVisible(true);

(Haven't actually compiled this...but the idea is right :-))
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"otnip otnip",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
Scott Florez
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I use with JPGs, all in one line, which I have compiled and know it works :-)

Good luck!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!