Solved

JOptionPane Icons

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

760 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

16 Experts available now in Live!

Get 1:1 Help Now