Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane question  RSS feed

 
Nick Optik
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use an image such as a gif or jpeg as a custome icon in a JOptionPane dialog, if so how do you do it. If not what would be a good alternative.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several of the constructors for JOptionPane, as well as one version of each of the showXXXDialog() methods, takes an Icon as an argument. Pass in an ImageIcon object. Construct the ImageIcon using the path to the image file as the constructor parameter.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Nick!
If you haven't already discovered it, you might find the J2SE API documentation useful when trying to figure out how to use some class. In particular, the JOptoinPane class documenation might help to point you in the right direction.
Now, since we've a forum dedicated to this fancy GUI stuff, I'm moving this to the Swing / JFC / AWT forum...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!