aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes setting up image wont work after click a button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting up image wont work after click a button" Watch "setting up image wont work after click a button" New topic
Author

setting up image wont work after click a button

shaon husain
Ranch Hand

Joined: Mar 20, 2013
Posts: 36
im having trouble in adding an image after a button is clicked, ive only added the code with the jlabel/imageicon


i always get null for the path, what could be the problem

the image path is correct as when i tested another way



the image appears, but this is done when i run it, the image is there already and not when i click a button.


thanks
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

shaon husain wrote:
i always get null for the path, what could be the problem

1) Does the image exist under the path you are specifying?
2) Check case sensitivity in the file name e.g. PNG instead of png


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
shaon husain
Ranch Hand

Joined: Mar 20, 2013
Posts: 36
Maneesh Godbole wrote:
shaon husain wrote:
i always get null for the path, what could be the problem

1) Does the image exist under the path you are specifying?
2) Check case sensitivity in the file name e.g. PNG instead of png

sorry for long reply,
but the path is correct, what else could be the problem
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 150
- don't to reacreate container with JLabel contains Icon/ImageIcon

- use JLabel.setIcon(loaded_Icon)

- otherwise required to notify already visible contianer with container.revalidate() and container.repaint(), as last code line, one time, after all changes are done

- use CardLayout instead, then any JButtons Action will be only switch betweens cards
shaon husain
Ranch Hand

Joined: Mar 20, 2013
Posts: 36
solved
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting up image wont work after click a button
 
Similar Threads
GIF image not getting displayed from an executable jar
Accessing image files of user entered paths
Reg: Running Swing in Browser
JLabel , image
Loading an Image