Re: using JOptionPane's error icon



On 27-4-2005 6:37, hkongogo@xxxxxxxxx wrote:
I'm writing my own error msg dialog and want to use the JOptionPane's
error icon. Pls help

UIManager.getIcon("OptionPane.errorIcon");

For other icons, see following program:

import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;

public class OptionPaneIcons {

   public static void main(String[] args) {

      JPanel jContentPane = new JPanel();
      jContentPane.setLayout(new FlowLayout());

      JLabel jLabel1 = new JLabel();
      jLabel1.setIcon(UIManager.getIcon("OptionPane.questionIcon"));
      jContentPane.add(jLabel1, null);

      JLabel jLabel2 = new JLabel();
      jLabel2.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
      jContentPane.add(jLabel2, null);

      JLabel jLabel3 = new JLabel();
      jLabel3.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
      jContentPane.add(jLabel3, null);

      JLabel jLabel4 = new JLabel();
      jLabel4.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
      jContentPane.add(jLabel4, null);

      JFrame application = new JFrame();
      application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      application.setContentPane(jContentPane);
      application.pack();
      application.setLocationRelativeTo(null);
      application.setVisible(true);
   }
}
--
Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \
.