JOptionPane: showOptionDialog(Component p, Object m, String t, int o, int me, Icon i, Object[] o, Object in) : JOptionPane « javax.swing « Java by API






JOptionPane: showOptionDialog(Component p, Object m, String t, int o, int me, Icon i, Object[] o, Object in)

 

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;

import javax.swing.Icon;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;

public class MainClass {

  public static void main(String[] a) {
    Icon blueIcon = new MyIcon(Color.BLUE);
    Object stringArray[] = { "Do It", "No Way" };
    JOptionPane.showOptionDialog(new JDesktopPane(), "Continue printing?", "Select an Option",
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray,
        stringArray[0]);

  }
}

class MyIcon implements Icon {
  Color myColor;

  public MyIcon(Color myColor) {
    this.myColor = myColor;
  }

  public int getIconWidth() {
    return 16;
  }

  public int getIconHeight() {
    return 16;
  }

  public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(myColor);
    g.drawRect(0, 0, 16, 16);
  }
}

           
         
  








Related examples in the same category

1.OptionPane.cancelButtonText
2.JOptionPane.CANCEL_OPTION
3.JOptionPane.CLOSED_OPTION
4.JOptionPane.DEFAULT_OPTION
5.JOptionPane.INFORMATION_MESSAGE
6.JOptionPane.NO_OPTION
7.OptionPane.noButtonText
8.OptionPane.okButtonText
9.JOptionPane.OK_CANCEL_OPTION
10.JOptionPane.QUESTION_MESSAGE
11.JOptionPane.YES_NO_OPTION
12.JOptionPane.YES_OPTION
13.OptionPane.yesButtonText
14.JOptionPane.UNINITIALIZED_VALUE
15.JOptionPane.WARNING_MESSAGE
16.JOptionPane: createDialog(Component parentComponent, String title)
17.JOptionPane: getMaxCharactersPerLineCount()
18.JOptionPane: setMessage(Object newMessage)
19.JOptionPane: setMessage(Object newMessage) (HTML message)
20.JOptionPane: setMessage(Object newMessage) (Component Array)
21.JOptionPane: setMessageType(int newType)
22.JOptionPane: setOptions(Object[] newOptions)
23.JOptionPane.setOptionType(int newType)
24.JOptionPane: showConfirmDialog(Component parentComponent, Object message)
25.JOptionPane: showConfirmDialog(Component parentComponent, Object message, String title, int optionType)
26.JOptionPane: showInputDialog(Object message)
27.JOptionPane: showInputDialog(Component p, Object m, String t, int m, Icon i, Object[] o, Object i)
28.JOptionPane: showInternalInputDialog(Component parentComponent, Object message)
29.JOptionPane: showInternalConfirmDialog(Component parentComponent, Object message)
30.JOptionPane.showInternalMessageDialog(Component parentComponent, Object message)
31.JOptionPane: showMessageDialog(Component parentComponent, Object message)