• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JToolBar icons not seen

 
Mousa A. Rafi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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.
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic