Solved

JOptionPane Icons

Posted on 2001-08-18
2
1,205 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 63
servlet  URL Rewriting 1 42
MySqlDump not dumping triggers 1 43
Configure a Bean in an XML file 4 42
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…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

829 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