JOptionPane.CLOSED_OPTION : JOptionPane « javax.swing « Java by API






JOptionPane.CLOSED_OPTION

  
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main extends JFrame {
  public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(new JLabel("Placeholder label"));
    pack();
    setSize(200, 200);
    setVisible(true);

    int replaced = JOptionPane.showConfirmDialog(this,
        "Replace existing selection?");

    String result = "?";
    switch (replaced) {
    case JOptionPane.CANCEL_OPTION:
      result = "Canceled";
      break;
    case JOptionPane.CLOSED_OPTION:
      result = "Closed";
      break;
    case JOptionPane.NO_OPTION:
      result = "No";
      break;
    case JOptionPane.YES_OPTION:
      result = "Yes";
      break;
    default:
      ;
    }
    System.out.println("Replace? " + result);
  }

  public static void main(String[] args) {
    new Main();
  }
}

   
    
  








Related examples in the same category

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