• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add image in a pop up

 
Tom Little
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to create a pop up window that will display an image.

Here is my code so far:



I know the code to make a pop up window that displays a message but I am not sure on how to display an image. Also my second question is: in the pop up window does the image have to be a real image such as a jpeg,png etc. or can I draw it myself within java?

Thank you!
 
Darryl Burke
Bartender
Posts: 5153
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "pop up window" -- JPopupMenu / Popup / JOptionPane#showMessageDialog(...) / something else ?

If the third named, you can pass an Icon as the message parameter.

does the image have to be a real image such as a jpeg,png etc. or can I draw it myself within java?

Either way, it's a real Image. Don't confuse an Image with the File it may have been loaded from.

You might want to look at the classes BufferedImage and ImageIcon.
 
Campbell Ritchie
Marshal
Posts: 52543
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum, where we usually discuss this sort of question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!