Solved

JOptionPane Icons

Posted on 2001-08-18
2
1,206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

726 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