This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting up image wont work after click a button

 
shaon husain
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
shaon husain
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- 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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
solved
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!