GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes JToolBar icons not seen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JToolBar icons not seen" Watch "JToolBar icons not seen" New topic
Author

JToolBar icons not seen

Mousa A. Rafi
Greenhorn

Joined: Jan 30, 2005
Posts: 28
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

Joined: Jan 14, 2004
Posts: 1535
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

Joined: Jan 30, 2005
Posts: 28
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.
 
GeeCON Prague 2014
 
subject: JToolBar icons not seen