aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Displaying Graphic Buttons on a Toolbar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Displaying Graphic Buttons on a Toolbar" Watch "Displaying Graphic Buttons on a Toolbar" New topic
Author

Displaying Graphic Buttons on a Toolbar

C Lindstrom
Greenhorn

Joined: Sep 19, 2000
Posts: 8
Hi,
I am trying to load an iconed button onto a toolbar. If the graphic file does not exist, results are the same. To me, this implies I am not calling the .gif incorrectly. My best attempt is a very small button, no icon.
Checked the JavaRanch messages, and could not find one that addressed this issue. If you remember reading a solution to this, please reply with the link. Apparently no one else has had a problem with this. Is there some kind of plug-in I am missing
This is from day 21 of Cadenhead & Lemay�s Professional Edition of Teach Yourself Java 2, p. 536.
The code has been edited in the interest of brevity. Initially there were three buttons.


Thanks, Connie
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
This works fine. Are you sure that the gif file is in the same directory as the java class? If the image file is not in the same directory as the java class, I get the very small box you described.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
C Lindstrom
Greenhorn

Joined: Sep 19, 2000
Posts: 8
Thomas,
Thank you for verifying the code worked correctly. Fiddled around with it, and found the codet worked correctly when the graphics were called with an absolute path - �C:\foo\bar\graphic.jpg� rather than �graphic.jpg�. The next question is "how is the cwd determined?", but that is a question for another forum.
My apologies for nuisancing this forum with a non-swing inquiry.
Connie
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Connie, we have had several questions in several forums regarding loading images. A bunch were resolved by the solution you referred to: absolute path. Are you aware of any way to load an image file using relative paths? I haven't had a chance to search the API for this info, but if you come across an answer, please post it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying Graphic Buttons on a Toolbar