Re: using JOptionPane's error icon



Mikael Flensborg wrote:
Think the question is misunderstood... He wants to use the ICON used in JOptionPane in other contexts, and NOT the JOptionPane itself... I have been looking for a way to do it too.. So far with no success.

AFAIK there is no official way, the icons are not part of the public API. You have a number of alternatives:


- Sun's icon repository contains some of them (but not all). If your icon is there, you could bundle the icon GIF and use that instead.

- You could look through the UI defaults. Sun's VMs uses some properties to point to the icons. However, this is an implementation detail, and other VM vendors might do it completely different.

- You could subclass BasicOptionPaneUI to get access to its getIcon...() method (I forgot the exact name). That method should be capable of delivering instances of the icons. However, BasicOptionPaneUI has for sure side-effects when one creates an instance of it. You have to check if they affect you.

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
.



Relevant Pages

  • Re: Icon in JOptionPane
    ... > should inherit the image from its parent. ... You are partially correct when you say that a Dialog inherits its icon ... The JOptionPane showXxxxDialog() just creates a normal JDialog, ...
    (comp.lang.java.gui)
  • Buttons with Icons in JOptionPane
    ... is it possible to display the buttons in a JOptionPane with Icons? ... parentComponent, Object message, String title, int optionType, int ... messageType, Icon icon, Objectoptions, Object initialValue). ...
    (comp.lang.java.gui)
  • Re: Icon in JOptionPane
    ... >> I want to set the title bar icon for my JOptionPane.showXXXXdialog. ... >> Since JOptionPane has no method to do so, ... >> should inherit the image from its parent. ...
    (comp.lang.java.gui)