Solved

JOptionPane Icons

Posted on 2001-08-18
2
1,203 Views
Last Modified: 2008-03-10
I have a couple of JInternalPane's that could use some icons.

The JOptionPane's icons work great, however I don't want to actually create a JOptionPane to get at them. I tried to track them down by looking at Sun's source code and by looking through the jars in the jre\lib directory (rt.jar, etc) and lib directory (tools.jar, etc).

But no Luck.

Anyone know where they hide these things?
Better yet, does anyone know of a way to grab them from code without creating an instance of JOptionPane?
0
Comment
Question by:mbunkows
2 Comments
 
LVL 15

Accepted Solution

by:
ozymandias earned 200 total points
ID: 6403228
These icons are managed by the UIManager and are stored inthe UIDefaults hashtable.

You can get at them like this :

import java.awt.*;
import javax.swing.*;

public class UIIcons extends JFrame{

     Container contentPane;

     public UIIcons(String[] args){
          super("UIIcons");
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
          contentPane = this.getContentPane();
          contentPane.setLayout(new FlowLayout());
          contentPane.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
          contentPane.add(new JLabel(UIManager.getIcon("OptionPane.informationIcon")));
          contentPane.add(new JLabel(UIManager.getIcon("OptionPane.questionIcon")));
          contentPane.add(new JLabel(UIManager.getIcon("OptionPane.warningIcon")));
     }

     public static void main(String[] args){
          UIIcons mc = new UIIcons(args);
          mc.setSize(300,100);
          mc.setVisible(true);
     }
}
0
 

Author Comment

by:mbunkows
ID: 6403932
Perfect, thanks.
I don't know why I didn't catch that when I was looking at the source.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now