Example usage for javax.swing JOptionPane JOptionPane

List of usage examples for javax.swing JOptionPane JOptionPane

Introduction

In this page you can find the example usage for javax.swing JOptionPane JOptionPane.

Prototype

public JOptionPane(Object message, int messageType, int optionType, Icon icon) 

Source Link

Document

Creates an instance of JOptionPane to display a message with the specified message type, options, and icon.

Usage

From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java

/**
 * Delete multiple rows//from www.ja  v  a 2 s  .co  m
 *
 * @param index - array of ints containing indexes to remove.
 */
protected void deleteRow(int[] index) {
    spreadsheet.rowsToDelete = index;
    spreadsheet.currentState = Spreadsheet.DELETING_ROW;

    spreadsheet.optionPane = new JOptionPane(
            "<html>Are you sure you want to delete these rows? <p>This Action can not be undone!</p></html>",
            JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION, spreadsheet.confirmRemoveRowIcon);
    spreadsheet.optionPane.addPropertyChangeListener(spreadsheet);
    UIHelper.applyOptionPaneBackground(spreadsheet.optionPane, UIHelper.BG_COLOR);
    spreadsheet.getParentFrame()
            .showJDialogAsSheet(spreadsheet.optionPane.createDialog(spreadsheet, "Confirm Delete Rows"));
}

From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java

/**
 * Delete a row with a given index./*from w  w w . ja v a2  s .  c o m*/
 *
 * @param index - index of row to remove
 */
protected void deleteRow(int index) {
    spreadsheet.rowsToDelete = new int[] { index };
    spreadsheet.currentState = Spreadsheet.DELETING_ROW;

    spreadsheet.optionPane = new JOptionPane(
            "<html>Are you sure you want to delete this row? <p>This Action can not be undone!</p></html>",
            JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION, spreadsheet.confirmRemoveRowIcon);
    spreadsheet.optionPane.addPropertyChangeListener(spreadsheet);
    UIHelper.applyOptionPaneBackground(spreadsheet.optionPane, UIHelper.BG_COLOR);
    spreadsheet.getParentFrame()
            .showJDialogAsSheet(spreadsheet.optionPane.createDialog(spreadsheet, "Confirm Delete Rows"));
}

From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java

private boolean stopConfirm() {
    JOptionPane pane = new JOptionPane("Do you want to stop recording?", JOptionPane.WARNING_MESSAGE,
            JOptionPane.YES_NO_OPTION, null);
    JDialog dialog = pane.createDialog(SwingUtilities.getWindowAncestor(this), "Stop recording");
    dialog.setVisible(true);/*from  ww  w  .  ja v  a  2 s.  com*/
    Object selectedValue = pane.getValue();
    if (selectedValue == null) {
        return false;
    }
    return JOptionPane.YES_OPTION == (Integer) selectedValue;
}

From source file:org.nuclos.client.main.MainController.java

public static void cmdOpenSettings() {
    NuclosSettingsContainer panel = new NuclosSettingsContainer(frm);

    JOptionPane p = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null);
    JDialog dlg = p.createDialog(Main.getInstance().getMainFrame(),
            SpringLocaleDelegate.getInstance().getMessage("R00022927", "Einstellungen"));
    dlg.pack();//from  ww  w .j  av  a  2  s . com
    dlg.setResizable(true);
    dlg.setVisible(true);
    Object o = p.getValue();
    int res = ((o instanceof Integer) ? ((Integer) o).intValue() : JOptionPane.CANCEL_OPTION);

    if (res == JOptionPane.OK_OPTION) {
        try {
            panel.save();
        } catch (PreferencesException e) {
            Errors.getInstance().showExceptionDialog(frm, e);
        }
    }
}