Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java coffee cup in GUI  RSS feed

 
Dar Var
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm interested in two things

1)What code do I use to change the Java coffe cup icon in the title bar of a JFrame.

2) I have a gif which is 42x20 in size and 256 colors. What tool can I use to create an image to use in the title bar. And does the tool make it into a gif, jpeg, ico that will be easy to make out in the small space its given...Also what the code to add this.
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi var,

To set frame icon use "setIconImage(Image img)" method. Image class is from java.awt and ImageIcon is from javax.swing package.

eg.,
setIconImage(new ImageIcon("c:/images/img5.png").getImage());

comming to the type and size of image. as far as i tried except bitmap file (.bmp) we can set any type of image and that image will be resized to default height and width of frame titlebar icon.

Hope This Helps

All The Best
[ March 24, 2005: Message edited by: sasi kala ]
 
Dar Var
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya the code works okay but the image looks really bad in the title bar. Is there a way of creating an image so it looks as goog as the Java coffe cup
 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make the icon square. If you don't like the way Java will shrink it to the size of the icon (might blur unusually), use an editor and shrink it yourself to fit.
 
Dar Var
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What size is the icon in the GUI
 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Common size on a windows system is 16x16. However, I'd suggest a 32x32 in case it's slightly larger.. I'd rather have it shrink automatically rather than expand.
 
Anwar Hossain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setIconImage() is working only for GUI otherthen frame.Can anyone give me the solution?

Anwar
SCJP2,MCP
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!