Java Code Examples for javax.swing.JOptionPane.DEFAULT_OPTION

The following are Jave code examples for showing how to use DEFAULT_OPTION of the javax.swing.JOptionPane class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: org.alloytools.alloy   File: OurDialog.java   View Source Code Vote up 7 votes
/** Helper method for constructing an always-on-top modal dialog. */
private static Object show(String title, int type, Object message, Object[] options, Object initialOption) {
	if (options == null) {
		options = new Object[] {
				"Ok"
		};
		initialOption = "Ok";
	}
	JOptionPane p = new JOptionPane(message, type, JOptionPane.DEFAULT_OPTION, null, options, initialOption);
	p.setInitialValue(initialOption);
	JDialog d = p.createDialog(null, title);
	p.selectInitialValue();
	d.setAlwaysOnTop(true);
	d.setVisible(true);
	d.dispose();
	return p.getValue();
}
 
Example 2
Project: incubator-netbeans   File: DialogDisplayerImplTest.java   View Source Code Vote up 5 votes
@Override
protected void setUp() throws Exception {
    LOG = Logger.getLogger("test." + getName());
    dd = new DialogDisplayerImpl (RESULT);
    closeOwner = new JButton ("Close this dialog");
    childDD = new DialogDescriptor ("Child", "Child", false, null);
    openChild = new JButton ("Open child");
    closeChild = new JButton ("Close child");
    pane = new JOptionPane ("", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {openChild, closeChild});
}
 
Example 3
Project: org.alloytools.alloy   File: OurDialog.java   View Source Code Vote up 5 votes
/**
 * Popup the given informative message, then ask the user to click Close to
 * close it.
 */
public static void showmsg(String title, Object... msg) {
	JButton dismiss = new JButton(Util.onMac() ? "Dismiss" : "Close");
	Object[] objs = new Object[msg.length + 1];
	System.arraycopy(msg, 0, objs, 0, msg.length);
	objs[objs.length - 1] = OurUtil.makeH(null, dismiss, null);
	JOptionPane about = new JOptionPane(objs, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
			new Object[] {});
	JDialog dialog = about.createDialog(null, title);
	dismiss.addActionListener(Runner.createDispose(dialog));
	dialog.setAlwaysOnTop(true);
	dialog.setVisible(true);
	dialog.dispose();
}
 
Example 4
Project: Tarski   File: OurDialog.java   View Source Code Vote up 5 votes
/** Helper method for constructing an always-on-top modal dialog. */
private static Object show(String title, int type, Object message, Object[] options, Object initialOption) {
   if (options == null) { options = new Object[]{"Ok"};  initialOption = "Ok"; }
   JOptionPane p = new JOptionPane(message, type, JOptionPane.DEFAULT_OPTION, null, options, initialOption);
   p.setInitialValue(initialOption);
   JDialog d = p.createDialog(null, title);
   p.selectInitialValue();
   d.setAlwaysOnTop(true);
   d.setVisible(true);
   d.dispose();
   return p.getValue();
}
 
Example 5
Project: Tarski   File: OurDialog.java   View Source Code Vote up 5 votes
/** Popup the given informative message, then ask the user to click Close to close it. */
public static void showmsg(String title, Object... msg) {
   JButton dismiss = new JButton(Util.onMac() ? "Dismiss" : "Close");
   Object[] objs = new Object[msg.length + 1];
   System.arraycopy(msg, 0, objs, 0, msg.length);
   objs[objs.length - 1] = OurUtil.makeH(null, dismiss, null);
   JOptionPane about = new JOptionPane(objs, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{});
   JDialog dialog = about.createDialog(null, title);
   dismiss.addActionListener(Runner.createDispose(dialog));
   dialog.setAlwaysOnTop(true);
   dialog.setVisible(true);
   dialog.dispose();
}
 
Example 6
Project: Tarski   File: OurDialog.java   View Source Code Vote up 5 votes
/** Helper method for constructing an always-on-top modal dialog. */
private static Object show(String title, int type, Object message, Object[] options, Object initialOption) {
   if (options == null) { options = new Object[]{"Ok"};  initialOption = "Ok"; }
   JOptionPane p = new JOptionPane(message, type, JOptionPane.DEFAULT_OPTION, null, options, initialOption);
   p.setInitialValue(initialOption);
   JDialog d = p.createDialog(null, title);
   p.selectInitialValue();
   d.setAlwaysOnTop(true);
   d.setVisible(true);
   d.dispose();
   return p.getValue();
}
 
Example 7
Project: Tarski   File: OurDialog.java   View Source Code Vote up 5 votes
/** Popup the given informative message, then ask the user to click Close to close it. */
public static void showmsg(String title, Object... msg) {
   JButton dismiss = new JButton(Util.onMac() ? "Dismiss" : "Close");
   Object[] objs = new Object[msg.length + 1];
   System.arraycopy(msg, 0, objs, 0, msg.length);
   objs[objs.length - 1] = OurUtil.makeH(null, dismiss, null);
   JOptionPane about = new JOptionPane(objs, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{});
   JDialog dialog = about.createDialog(null, title);
   dismiss.addActionListener(Runner.createDispose(dialog));
   dialog.setAlwaysOnTop(true);
   dialog.setVisible(true);
   dialog.dispose();
}
 
Example 8
Project: incubator-netbeans   File: AutoUpgrade.java   View Source Code Vote up 4 votes
private static void showNoteDialog (String note) {
    Util.setDefaultLookAndFeel();
    JOptionPane p = new JOptionPane(new AutoUpgradePanel (null, note), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION);
    JDialog d = Util.createJOptionDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Note_Title"));
    d.setVisible (true);
}
 
Example 9
Project: JavaGraph   File: ErrorDialog.java   View Source Code Vote up 4 votes
/**
 * Constructs a new error dialog, with the same top-level frame as the given
 * component, a simple error message, and an exception giving more detail
 * about the error. The dialog is not yet shown.
 */
public ErrorDialog(Component component, String message, Throwable exc) {
    super(getParentFrame(component), ERROR_MESSAGE_TEXT, true);
    setLocationRelativeTo(component);
    this.exc = exc;

    // setup cancel button
    JComponent cancelPane = Box.createHorizontalBox();
    this.cancelButton = new JButton(CANCEL_BUTTON_TEXT);
    cancelPane.add(Box.createHorizontalGlue());
    cancelPane.add(this.cancelButton);
    cancelPane.add(Box.createHorizontalGlue());
    this.cancelButton.setSelected(true);

    // setup details pane
    this.detailsButton = new JButton(NO_DETAILS_BUTTON_TEXT);
    this.detailsButton.setEnabled(exc != null);
    JComponent detailsButtonPane = Box.createHorizontalBox();
    detailsButtonPane.add(this.cancelButton);
    detailsButtonPane.add(Box.createHorizontalGlue());
    detailsButtonPane.add(this.detailsButton);

    this.detailsPane = new JPanel(new BorderLayout());
    this.detailsPane.add(detailsButtonPane, BorderLayout.SOUTH);

    // setup message pane
    JPanel messagePane = new JPanel(new BorderLayout());
    messagePane.setPreferredSize(new Dimension(300, 100));
    messagePane.add(this.detailsPane, BorderLayout.CENTER);

    // setup option pane
    JOptionPane optionPane =
        new JOptionPane(message, JOptionPane.ERROR_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
            new Object[] {messagePane});
    optionPane.add(messagePane, BorderLayout.SOUTH);
    // setup content pane
    Container contentPane = getContentPane();
    contentPane.add(optionPane);
    // constrain size to maximum
    setPreferredSize();

    // setup text area
    this.detailsArea = new JTextArea();
    this.detailsArea.setEditable(false);
    this.detailsTextPane = new JScrollPane(this.detailsArea);
    this.detailsTextPane.setPreferredSize(new Dimension(300, 100));
    this.detailsTextPane.setBorder(new EmptyBorder(5, 0, 5, 0));
    setDetailsLevel(NO_DETAILS);

    // setup button listener
    ActionListener buttonListener = new ButtonListener();
    this.cancelButton.addActionListener(buttonListener);
    this.detailsButton.addActionListener(buttonListener);
    pack();
}
 
Example 10
Project: JavaGraph   File: Imager.java   View Source Code Vote up 2 votes
/**
 * Creates and returns a plain option pane on the basis of a given
 * message panel and row of buttons.
 * @param messagePane the central message pane
 * @param buttonRow the buttons to be displayed at the bottom of the
 *        pane
 */
protected JOptionPane createOptionPane(JPanel messagePane, JButton[] buttonRow) {
    return new JOptionPane(messagePane, JOptionPane.PLAIN_MESSAGE,
        JOptionPane.DEFAULT_OPTION, null, buttonRow);
}