• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JToolBar icons not seen

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's how I'm trying to use a toolbar:
First create a ImageIcon type object and create an Action.

Then somewhere registering the action with the toolbar:


When I run this, there appears small boxes in the toolbar and by click them I achieve their desired behaviour. It's only the image that should be shown in the boxes do not appear.

I confirmed the existence and actual name of the image file. It's in the same directory where the .java file is.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way I could get the image to not show up was to either load it after the AbstractAction had been instantiated, say, in the class constructor, or give a bad path to the image file. One problem with the ImageIcon loading method is that we don't get any feedback for load failures. Here's a suggestion that may help avoid both problems, ie, unannounced load failure and timing discrepencies in instantiation of the ImageIcon and the AbstractAction that will use it.
 
Mousa A. Rafi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Craig Wood. That piece of program told be that I was doing something wrong and then found how stupid I've been not to check if the class files were created in the same directory where the java and image files are. I was using JCreator and for some reason it created the class files in a different place. So, when tried to execute (also with JCreator) they didn't find the images.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic