Example usage for javax.swing JOptionPane VALUE_PROPERTY

List of usage examples for javax.swing JOptionPane VALUE_PROPERTY

Introduction

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

Prototype

String VALUE_PROPERTY

To view the source code for javax.swing JOptionPane VALUE_PROPERTY.

Click Source Link

Document

Bound property name for value.

Usage

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display errors in import dialog // ww w .ja va2  s  .c o m
 * 
 * @param frame - parent frame
 */
private void importErrorsCollected(Component frame) {
    final JOptionPane optionPane = new JOptionPane(
            "\nYour import has produced one or more errors, " + "\nvisit the 'Import Errors' tab for details.",
            JOptionPane.WARNING_MESSAGE);
    final JDialog errorDialog = new JDialog(this, "Errors Collected", false);
    errorDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (errorDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                errorDialog.dispose();
            }
        }
    });

    errorDialog.toFront();
    errorDialog.pack();
    errorDialog.setLocationRelativeTo(frame);
    errorDialog.setVisible(true);
}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display errors in candidates dialog//w  w  w .  j a  va2s  .  co  m
 * 
 * @param frame - parent frame
 */
public void candidateErrorsCollected(Component frame) {
    errors_pending = false;
    final JOptionPane optionPane = new JOptionPane(
            "\nAdding these files to the queue has produced one or more errors and some"
                    + "\n files will not be displayed on the queue. View the 'Import Errors' tab for details.",
            JOptionPane.WARNING_MESSAGE);
    final JDialog errorDialog = new JDialog(this, "Errors Collected", true);
    errorDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (errorDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                errorDialog.dispose();
            }
        }
    });

    errorDialog.toFront();
    errorDialog.pack();
    errorDialog.setLocationRelativeTo(frame);
    errorDialog.setVisible(true);
}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display failed sending errors dialog//from   w  w  w .ja  va2s. c  o m
 * 
 * @param frame - parent frame
 */
public void sendingErrorsFailed(Component frame) {
    final JOptionPane optionPane = new JOptionPane(
            "\nDue to an error we were not able to send your error messages."
                    + "\nto our feedback server. Please try again.",
            JOptionPane.WARNING_MESSAGE);

    final JDialog failedDialog = new JDialog(this, "Feedback Failed!", true);

    failedDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (failedDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                failedDialog.dispose();
            }
        }
    });

    failedDialog.toFront();
    failedDialog.pack();
    failedDialog.setLocationRelativeTo(frame);
    failedDialog.setVisible(true);
}

From source file:ome.formats.importer.gui.ImportDialog.java

/**
 * Dialog explaining metadata limitations when changing the main dialog's naming settings
 * /* www.j  a va2  s .c o m*/
 * @param frame - parent component
 */
public void sendNamingWarning(Component frame) {
    final JOptionPane optionPane = new JOptionPane(
            "\nNOTE: Some file formats do not include the file name in their metadata, "
                    + "\nand disabling this option may result in files being imported without a "
                    + "\nreference to their file name. For example, 'myfile.lsm [image001]' "
                    + "\nwould show up as 'image001' with this optioned turned off.",
            JOptionPane.WARNING_MESSAGE);
    final JDialog warningDialog = new JDialog(this, "Naming Warning!", true);
    warningDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (warningDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                warningDialog.dispose();
            }
        }
    });

    warningDialog.toFront();
    warningDialog.pack();
    warningDialog.setLocationRelativeTo(frame);
    warningDialog.setVisible(true);
}

From source file:org.docx4all.swing.ExternalHyperlinkDialog.java

/** This method reacts to state changes in the option pane. */
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible() && (e.getSource() == this.optionPane)
            && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
        Object userAnswer = this.optionPane.getValue();

        if (userAnswer == JOptionPane.UNINITIALIZED_VALUE) {
            //ignore reset
            return;
        }/*ww w  . ja va2  s  .c  o  m*/

        //Reset the JOptionPane's value.
        //If you don't do this, then if the user
        //presses the same button next time, no
        //property change event will be fired.
        this.optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

        setVisible(false);

        if (OK_BUTTON_TEXT.equals(userAnswer)) {
            this.value = OK_BUTTON_TEXT;

            StringBuilder target = new StringBuilder();
            if (isSourceFileDirectory(this.directoryUrlPath)) {
                target.append(this.documentNameField.getText());
            } else {
                target.append(VFSUtils.getFriendlyName(this.directoryUrlPath, false));
                target.append("/");
                target.append(this.documentNameField.getText());
            }
            if (!target.toString().endsWith(".docx")) {
                target.append(".docx");
            }

            if (this.hyperlinkML.canSetTarget()) {
                this.hyperlinkML.setTarget(target.toString());
            } else {
                this.hyperlinkML.setDummyTarget(target.toString());
            }

            if (this.displayTextField.getText().length() == 0) {
                this.hyperlinkML.setDisplayText(target.toString());
            } else {
                this.hyperlinkML.setDisplayText(this.displayTextField.getText());
            }
            this.hyperlinkML.setTooltip(this.tooltipField.getText());

        } else {
            //User closed dialog or clicked cancel
            this.value = CANCEL_BUTTON_TEXT;
        }

        //do not keep a reference to the edited hyperlinkML
        //so that this dialog can be disposed of.
        this.hyperlinkML = null;
    }
}

From source file:org.isatools.isacreator.gui.formelements.SubForm.java

private void removalConfirmation(final FieldTypes whatIsBeingRemoved) {
    // delete reference to protocol in subform

    // add one to take into account the model and the initial column which contains fields names.
    final int selectedItem = scrollTable.getSelectedColumn() + 1;

    // check to ensure the value isn't 0, if it is, nothing is selected in the table since -1 (value returned by model if
    // no column is selected + 1 = 0!)
    if ((selectedItem != 0) && (dataEntryForm != null)) {
        String displayText;/*from   w  w  w  .  ja  v  a  2  s  .  c o  m*/
        if ((whatIsBeingRemoved == FieldTypes.FACTOR) || (whatIsBeingRemoved == FieldTypes.PROTOCOL)) {
            displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this "
                    + fieldType + " will result in all " + fieldType + "s of this type in subsequent assays</p>"
                    + "<p>being deleted too! Do you wish to continue?</p>" + "</html>";
        } else {
            displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this "
                    + fieldType + " will result in its complete removal from this experiment annotation!</p>"
                    + "<p>Do you wish to continue?</p>" + "</html>";
        }

        JOptionPane optionPane = new JOptionPane(displayText, JOptionPane.INFORMATION_MESSAGE,
                JOptionPane.YES_NO_OPTION);
        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                    int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());

                    if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                        removeItem(selectedItem);
                        ApplicationManager.getCurrentApplicationInstance().hideSheet();
                    } else {
                        // just hide the sheet and cancel further actions!
                        ApplicationManager.getCurrentApplicationInstance().hideSheet();
                    }
                }
            }
        });
        optionPane.setIcon(confirmRemoveColumn);
        UIHelper.applyOptionPaneBackground(optionPane, UIHelper.BG_COLOR);
        ApplicationManager.getCurrentApplicationInstance()
                .showJDialogAsSheet(optionPane.createDialog(this, "Confirm Delete"));
    } else {
        removeColumn(selectedItem);
    }
}

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

/**
 * Create the FlatButton panel - a panel which contains graphical representations of the options available
 * to the user when interacting with the software.
 *///from   w  w  w.  j  a v  a 2s .com
private void createButtonPanel() {

    spreadsheetFunctionPanel = new JPanel();
    spreadsheetFunctionPanel.setLayout(new BoxLayout(spreadsheetFunctionPanel, BoxLayout.LINE_AXIS));
    spreadsheetFunctionPanel.setBackground(UIHelper.BG_COLOR);

    addRow = new JLabel(addRowButton);
    addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>");
    addRow.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButton);
            showMultipleRowsGUI();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButton);
        }
    });

    deleteRow = new JLabel(deleteRowButton);
    deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>");
    deleteRow.setEnabled(false);
    deleteRow.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButton);
            if (table.getSelectedRow() != -1) {
                if (!(table.getSelectedRowCount() > 1)) {
                    spreadsheetFunctions.deleteRow(table.getSelectedRow());
                } else {
                    spreadsheetFunctions.deleteRow(table.getSelectedRows());
                }

            }
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButton);
        }
    });

    deleteColumn = new JLabel(deleteColumnButton);
    deleteColumn
            .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>");
    deleteColumn.setEnabled(false);
    deleteColumn.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButton);
            if (!(table.getSelectedColumns().length > 1)) {
                spreadsheetFunctions.deleteColumn(table.getSelectedColumn());
            } else {
                showColumnErrorMessage();
            }
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButton);
        }
    });

    multipleSort = new JLabel(multipleSortButton);
    multipleSort.setToolTipText(
            "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>");
    multipleSort.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButton);
            showMultipleColumnSortGUI();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButton);
        }
    });

    copyColDown = new JLabel(copyColDownButton);
    copyColDown.setToolTipText("<html><b>copy column downwards</b>"
            + "<p>duplicate selected column and copy it from the current</p>"
            + "<p>position down to the final row in the table</p></html>");
    copyColDown.setEnabled(false);
    copyColDown.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButton);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButtonOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButton);

            final int row = table.getSelectedRow();
            final int col = table.getSelectedColumn();

            if (row != -1 && col != -1) {
                JOptionPane copyColDownConfirmationPane = new JOptionPane(
                        "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy "
                                + "this column downwards?</p><p>This Action can not be undone!</p></html>",
                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

                copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon);
                UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR);

                copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent event) {
                        if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                            int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
                            parentFrame.hideSheet();
                            if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                                spreadsheetFunctions.copyColumnDownwards(row, col);
                            }
                        }
                    }
                });
                parentFrame.showJDialogAsSheet(
                        copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?"));
            }
        }
    });

    copyRowDown = new JLabel(copyRowDownButton);
    copyRowDown.setToolTipText(
            "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>"
                    + "<p>position down to the final row</p></html>");
    copyRowDown.setEnabled(false);
    copyRowDown.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButton);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButtonOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButton);

            final int row = table.getSelectedRow();

            JOptionPane copyRowDownConfirmationPane = new JOptionPane(
                    "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy "
                            + "this row downwards?</p><p>This Action can not be undone!</p>",
                    JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

            copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon);

            UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR);

            copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                        int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
                        parentFrame.hideSheet();
                        if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                            spreadsheetFunctions.copyRowDownwards(row);
                        }
                    }
                }
            });
            parentFrame.showJDialogAsSheet(
                    copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?"));
        }
    });

    addProtocol = new JLabel(addProtocolButton);
    addProtocol.setToolTipText(
            "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>");
    addProtocol.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButton);
            if (addProtocol.isEnabled()) {
                FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF",
                        "Protocol used for experiment", DataTypes.LIST, "", false, false, false);

                fo.setFieldList(studyDataEntryEnvironment.getProtocolNames());

                spreadsheetFunctions.addFieldToReferenceObject(fo);

                spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1);
            }
        }
    });

    addFactor = new JLabel(addFactorButton);
    addFactor.setToolTipText(
            "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>");
    addFactor.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButton);
            if (addFactor.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN);
            }
        }
    });

    addCharacteristic = new JLabel(addCharacteristicButton);
    addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>"
            + "<p>Add a characteristic column to the table</p></html>");
    addCharacteristic.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButton);
            if (addCharacteristic.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN);
            }
        }
    });

    addParameter = new JLabel(addParameterButton);
    addParameter.setToolTipText(
            "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>");
    addParameter.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButton);
            if (addParameter.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN);
            }
        }
    });

    undo = new JLabel(undoButton);
    undo.setToolTipText("<html><b>undo previous action<b></html>");
    undo.setEnabled(undoManager.canUndo());
    undo.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            undo.setIcon(undoButton);
            undoManager.undo();

            if (highlightActive) {
                setRowsToDefaultColor();
            }
            table.addNotify();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            undo.setIcon(undoButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            undo.setIcon(undoButton);
        }
    });

    redo = new JLabel(redoButton);
    redo.setToolTipText("<html><b>redo action<b></html>");
    redo.setEnabled(undoManager.canRedo());
    redo.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            redo.setIcon(redoButton);
            undoManager.redo();

            if (highlightActive) {
                setRowsToDefaultColor();
            }
            table.addNotify();

        }

        public void mouseEntered(MouseEvent mouseEvent) {
            redo.setIcon(redoButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            redo.setIcon(redoButton);
        }
    });

    transpose = new JLabel(transposeIcon);
    transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>");
    transpose.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            transpose.setIcon(transposeIcon);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            transpose.setIcon(transposeIconOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            showTransposeSpreadsheetGUI();
        }
    });

    addButtons();

    if (studyDataEntryEnvironment != null) {
        JPanel labelContainer = new JPanel(new GridLayout(1, 1));
        labelContainer.setBackground(UIHelper.BG_COLOR);

        JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR,
                JLabel.RIGHT);
        lab.setBackground(UIHelper.BG_COLOR);
        lab.setVerticalAlignment(JLabel.CENTER);
        lab.setPreferredSize(new Dimension(200, 30));

        labelContainer.add(lab);

        spreadsheetFunctionPanel.add(labelContainer);
        spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10));
    }

    add(spreadsheetFunctionPanel, BorderLayout.NORTH);
}

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

public void propertyChange(PropertyChangeEvent event) {
    if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
        int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
        parentFrame.hideSheet();//ww w  .j a v a  2 s. c om

        if ((currentState == DELETING_COLUMN) && (lastOptionAnswer == JOptionPane.YES_OPTION)) {

            spreadsheetFunctions.removeColumn();
            curColDelete = -1;
            currentState = DEFAULT_STATE;
        }

        if ((currentState == DELETING_ROW) && (lastOptionAnswer == JOptionPane.YES_OPTION)) {
            spreadsheetFunctions.removeRows();
            rowsToDelete = null;
            currentState = DEFAULT_STATE;
        }

        currentState = DEFAULT_STATE;
        curColDelete = -1;
        rowsToDelete = null;
    }
}

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

/**
 * Delete column given an index./*  w w w. j a v  a  2s .  co m*/
 *
 * @param vColIndex - column to remove.
 */
protected void deleteColumn(int vColIndex) {
    spreadsheet.curColDelete = vColIndex;
    spreadsheet.currentState = Spreadsheet.DELETING_COLUMN;

    TableColumn col = spreadsheet.getTable().getColumnModel().getColumn(spreadsheet.curColDelete);

    if (!col.getHeaderValue().toString().equals(TableReferenceObject.ROW_NO_TEXT)) {
        if (spreadsheet.getTableReferenceObject().isRequired(col.getHeaderValue().toString())
                && !areMultipleOccurences(col.getHeaderValue().toString())) {
            spreadsheet.optionPane = new JOptionPane(
                    "<html>This column can not be deleted due to it being a required field in this assay!</html>",
                    JOptionPane.OK_OPTION);
            spreadsheet.optionPane.setIcon(spreadsheet.requiredColumnWarningIcon);
            UIHelper.applyOptionPaneBackground(spreadsheet.optionPane, UIHelper.BG_COLOR);

            spreadsheet.optionPane.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                        spreadsheet.getParentFrame().hideSheet();
                    }
                }
            });

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

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private void showMessagePane(String message, int messageType) {
    final JOptionPane optionPane = new JOptionPane("<html>" + message + "</html>", JOptionPane.OK_OPTION);
    UIHelper.renderComponent(optionPane, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    if (messageType == JOptionPane.ERROR_MESSAGE) {
        optionPane.setIcon(warningIcon);
    } else {/*from   w  ww.  jav  a  2s .c  om*/
        optionPane.setIcon(informationIcon);
    }

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                applicationContainer.hideSheet();
            }
        }
    });

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            applicationContainer.showJDialogAsSheet(optionPane.createDialog(getThis(), "Message"));
        }
    });

}