• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Displaying Graphic Buttons on a Toolbar

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
C Lindstrom
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bring out your dead! Or a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic