File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to open picture in JPanel

 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to open picture in JPanel??? I have code but it does not do anything=/
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating a new JLabel inside your action event is a very strange thing to do. You might be able to make that code work if you subsequently added the JLabel to your GUI, but in your case I would recommend you keep it simple. Use a JLabel which is already part of your GUI to display the picture.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you add components to an already realized container, you need to call revalidate(). In the case of removing components, it's necessary to additionally repaint() the container.

Since repaint() isn't usually computationally expensive, take the safe path and call both whenever you add or remove components.
 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Whenever you add components to an already realized container, you need to call revalidate(). In the case of removing components, it's necessary to additionally repaint() the container.

Since repaint() isn't usually computationally expensive, take the safe path and call both whenever you add or remove components.

cheers a lot!
 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Creating a new JLabel inside your action event is a very strange thing to do. You might be able to make that code work if you subsequently added the JLabel to your GUI, but in your case I would recommend you keep it simple. Use a JLabel which is already part of your GUI to display the picture.

Thank you!:)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic