Example usage for javax.swing JOptionPane CLOSED_OPTION

List of usage examples for javax.swing JOptionPane CLOSED_OPTION

Introduction

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

Prototype

int CLOSED_OPTION

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

Click Source Link

Document

Return value from class method if user closes window without selecting anything, more than likely this should be treated as either a CANCEL_OPTION or NO_OPTION.

Usage

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

@Override
public boolean aboutToShutdown() {
    boolean result = true;
    unlock();//w  w  w . ja  v  a2s  .c  om
    if (isChanged()) {
        String msg = String.format(getResourceString("SaveChanges"), getTitle());
        JFrame topFrame = (JFrame) UIRegistry.getTopWindow();

        int rv = JOptionPane.showConfirmDialog(topFrame, msg, getResourceString("SaveChangesTitle"),
                JOptionPane.YES_NO_CANCEL_OPTION);
        if (rv == JOptionPane.YES_OPTION) {
            saveQuery(false);
        } else if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
            return false;
        } else if (rv == JOptionPane.NO_OPTION) {
            // nothing
        }
    }
    return result;
}

From source file:com.xilinx.ultrascale.gui.MainScreen.java

private void videoplayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videoplayButtonActionPerformed
    // TODO add your handling code here:
    if (videoplayButton.getText().equalsIgnoreCase("Start")) {
        if (screenMode == 2 && ddrledState == 0) {// check for gencheck with card ddr.
            JOptionPane.showMessageDialog(this, "DDR4 not calibrated. Could not start the test.");
            return;
        }/*from   w w w . j  a va 2 s  . c  o m*/
        // conditional check for min and max
        if (pathFied.getText().length() == 0) {
            Object[] options1 = { "Ok" };
            int s = JOptionPane.showOptionDialog(null, "Please choose Video file path", " ",
                    JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, null);
            return;
        }
        if (Integer.parseInt(mincoeff.getValue().toString()) > Integer
                .parseInt(maxcoeff.getValue().toString())) {
            Object[] options1 = { "Ok" };
            int s = JOptionPane.showOptionDialog(null, "Min Threshold should always be less than Max Threshold",
                    " ", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, null);
            return;
        }
        messageLog2.append(">> Test Started\n");
        videoPauseButton.setEnabled(true);
        videoPauseButton.setText("Pause");
        videoplayButton.setText("Stop");
        pathFied.setEnabled(false);
        browseButton.setEnabled(false);
        //            mincoeff.setEnabled(false);
        //            maxcoeff.setEnabled(false);
        //            invertcheckbox.setEnabled(false);
        testStarted = true;

        di.startVideoTest(0, 7, Integer.parseInt(mincoeff.getValue().toString()),
                Integer.parseInt(maxcoeff.getValue().toString()), invertcheckbox.isSelected() ? 1 : 0, 7680);
        BGWorker worker = new BGWorker("./util/run_all_vlc.sh" + " start " + pathFied.getText());
        worker.execute();
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        testStarted = false;
        videoplayButton.setText("Start");
        videoPauseButton.setEnabled(false);
        BGWorker worker = new BGWorker("./kill_vlc.sh");
        worker.execute();

        pathFied.setEnabled(true);
        browseButton.setEnabled(true);
        //            mincoeff.setEnabled(true);
        //            maxcoeff.setEnabled(true);
        //            invertcheckbox.setEnabled(true);

        di.stopVideoTest(0, 7, 7680);

        axiTxTextField4.setText("0.000");
        axiRxTextField4.setText("0.000");
        //            ddrRxTextField.setText("0.000");
        //            ddrTxTextField.setText("0.000");

        pcieTxTextField4.setText("0.000");
        pcieRxTextField4.setText("0.000");
        messageLog2.append(">> Test Stopped\n");
        try {
            Thread.sleep(15000);
        } catch (InterruptedException ex) {
            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:com.xilinx.ultrascale.gui.MainScreen_video.java

private void videoplayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videoplayButtonActionPerformed

    // TODO add your handling code here:
    if (videoplayButton.getText().equalsIgnoreCase("Start")) {
        if (screenMode == 2 && ddrledState == 0) {// check for gencheck with card ddr.
            JOptionPane.showMessageDialog(this, "DDR4 not calibrated. Could not start the test.");
            return;
        }//from www.  j av a2  s.c o  m
        // conditional check for min and max
        if (pathFied.getText().length() == 0) {
            Object[] options1 = { "Ok" };
            int s = JOptionPane.showOptionDialog(null, "Please choose Video file path", " ",
                    JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, null);
            return;
        }
        if (Integer.parseInt(mincoeff.getValue().toString()) > Integer
                .parseInt(maxcoeff.getValue().toString())) {
            Object[] options1 = { "Ok" };
            int s = JOptionPane.showOptionDialog(null, "Min Threshold should always be less than Max Threshold",
                    " ", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, null);
            return;
        }
        // showing the videos panel

        //videoFrame.setLocationRelativeTo(this);
        videoFrame.setVisible(true);
        frame1.setVisible(true);
        frame2.setVisible(true);
        rxMediaPlayer.getMediaPlayer().playMedia("v4l2:///dev/video0");

        di.startVideoTest(0, 7, Integer.parseInt(mincoeff.getValue().toString()),
                Integer.parseInt(maxcoeff.getValue().toString()), invertcheckbox.isSelected() ? 1 : 0, 7680);

        Timer timers = new java.util.Timer();
        timers.schedule(new TimerTask() {
            @Override
            public void run() {
                txMediaPlayer.getMediaPlayer().playMedia(pathFied.getText());
                txMediaPlayer.getMediaPlayer().setRepeat(true);
            }
        }, 2000);

        //            txMediaPlayer.setRate((float) 16.0);
        messageLog2.append(">> Test Started\n");
        videoPauseButton.setEnabled(true);
        videoPauseButton.setText("Pause");
        videoplayButton.setText("Stop");
        pathFied.setEnabled(false);
        browseButton.setEnabled(false);
        //            mincoeff.setEnabled(false);
        //            maxcoeff.setEnabled(false);
        //            invertcheckbox.setEnabled(false);
        testStarted = true;

        //BGWorker worker1 = new BGWorker("./run_receive_vlc.sh");
        //worker1.execute();
        //            pworker = new ProcessWorker("./run_receive_vlc.sh");
        //            pworker.execute();
        //            try {
        //                Thread.sleep(500);
        //            } catch (InterruptedException ex) {
        //                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
        //            }
        //            worker = new BGWorker("./util/run_vlc.sh" + " start " + pathFied.getText());
        //            worker.execute();
        //            try {
        //                Thread.sleep(500);
        //            } catch (InterruptedException ex) {
        //                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
        //            }
    } else {
        testStarted = false;
        videoplayButton.setText("Wait");
        videoPauseButton.setEnabled(false);
        di.stopVideoTest(0, 7, 7680);
        //            if (worker1 != null){
        //                worker1.cancel(true);
        //                worker1 = null;
        //            }
        //            
        //            if(worker != null){
        //                worker.cancel(true);
        //                worker = null;
        //            }
        //            BGWorker worker1 = new BGWorker("./util/run_vlc.sh exit");
        //            worker1.execute();

        //pworker.p.destroy();
        txMediaPlayer.getMediaPlayer().stop();
        rxMediaPlayer.getMediaPlayer().stop();
        videoFrame.setVisible(false);
        frame1.setVisible(false);
        frame2.setVisible(false);

        pathFied.setEnabled(true);
        browseButton.setEnabled(true);
        //            mincoeff.setEnabled(true);
        //            maxcoeff.setEnabled(true);
        //            invertcheckbox.setEnabled(true);

        axiTxTextField4.setText("0.000");
        axiRxTextField4.setText("0.000");
        //            ddrRxTextField.setText("0.000");
        //            ddrTxTextField.setText("0.000");

        pcieTxTextField4.setText("0.000");
        pcieRxTextField4.setText("0.000");
        messageLog2.append(">> Test Stopped\n");
        //            try {
        //                Thread.sleep(15000);
        //            } catch (InterruptedException ex) {
        //                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
        //            }
        // disable button until the vlc rec window close.
        videoplayButton.setEnabled(false);
        Timer timers = new java.util.Timer();
        timers.schedule(new TimerTask() {
            @Override
            public void run() {
                enablePlayButton();
            }
        }, 3000);
    }

}

From source file:org.nuclos.client.ui.collect.Chart.java

private void actionCommandShow() {
    final JOptionPane optpn = new JOptionPane(subform, JOptionPane.PLAIN_MESSAGE, JOptionPane.CLOSED_OPTION);

    // perform the dialog:
    final JDialog dlg = optpn.createDialog(panel, "Chart-Daten anzeigen");
    dlg.setModal(true);/* w  w w.j a v  a2s  .  c o  m*/
    dlg.setResizable(true);
    dlg.pack();
    dlg.setLocationRelativeTo(panel);
    dlg.setVisible(true);
}

From source file:org.apache.jmeter.gui.action.Save.java

@Override
public void doAction(ActionEvent e) throws IllegalUserActionException {
    HashTree subTree = null;//w  w  w  .java2  s  .co  m
    boolean fullSave = false; // are we saving the whole tree?
    if (!commands.contains(e.getActionCommand())) {
        throw new IllegalUserActionException("Invalid user command:" + e.getActionCommand());
    }
    if (e.getActionCommand().equals(ActionNames.SAVE_AS)) {
        JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
        if (nodes.length > 1) {
            JMeterUtils.reportErrorToUser(JMeterUtils.getResString("save_as_error"), // $NON-NLS-1$
                    JMeterUtils.getResString("save_as")); // $NON-NLS-1$
            return;
        }
        subTree = GuiPackage.getInstance().getCurrentSubTree();
    } else if (e.getActionCommand().equals(ActionNames.SAVE_AS_TEST_FRAGMENT)) {
        JMeterTreeNode[] nodes = GuiPackage.getInstance().getTreeListener().getSelectedNodes();
        if (checkAcceptableForTestFragment(nodes)) {
            subTree = GuiPackage.getInstance().getCurrentSubTree();
            // Create Test Fragment node
            TestElement element = GuiPackage.getInstance()
                    .createTestElement(TestFragmentControllerGui.class.getName());
            HashTree hashTree = new ListedHashTree();
            HashTree tfTree = hashTree.add(new JMeterTreeNode(element, null));
            for (JMeterTreeNode node : nodes) {
                // Clone deeply current node
                TreeCloner cloner = new TreeCloner(false);
                GuiPackage.getInstance().getTreeModel().getCurrentSubTree(node).traverse(cloner);
                // Add clone to tfTree
                tfTree.add(cloner.getClonedTree());
            }

            subTree = hashTree;

        } else {
            JMeterUtils.reportErrorToUser(JMeterUtils.getResString("save_as_test_fragment_error"), // $NON-NLS-1$
                    JMeterUtils.getResString("save_as_test_fragment")); // $NON-NLS-1$
            return;
        }
    } else {
        fullSave = true;
        HashTree testPlan = GuiPackage.getInstance().getTreeModel().getTestPlan();
        // If saveWorkBench 
        if (isWorkbenchSaveable()) {
            HashTree workbench = GuiPackage.getInstance().getTreeModel().getWorkBench();
            testPlan.add(workbench);
        }
        subTree = testPlan;
    }

    String updateFile = GuiPackage.getInstance().getTestPlanFile();
    if (!ActionNames.SAVE.equals(e.getActionCommand()) || updateFile == null) {
        JFileChooser chooser = FileDialoger.promptToSaveFile(updateFile == null
                ? GuiPackage.getInstance().getTreeListener().getCurrentNode().getName() + JMX_FILE_EXTENSION
                : updateFile);
        if (chooser == null) {
            return;
        }
        updateFile = chooser.getSelectedFile().getAbsolutePath();
        // Make sure the file ends with proper extension
        if (FilenameUtils.getExtension(updateFile).isEmpty()) {
            updateFile = updateFile + JMX_FILE_EXTENSION;
        }
        // Check if the user is trying to save to an existing file
        File f = new File(updateFile);
        if (f.exists()) {
            int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
                    JMeterUtils.getResString("save_overwrite_existing_file"), // $NON-NLS-1$
                    JMeterUtils.getResString("save?"), // $NON-NLS-1$
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.NO_OPTION) {
                return; // Do not save, user does not want to overwrite
            }
        }

        if (!e.getActionCommand().equals(ActionNames.SAVE_AS)) {
            GuiPackage.getInstance().setTestPlanFile(updateFile);
        }
    }

    // backup existing file according to jmeter/user.properties settings
    List<File> expiredBackupFiles = EMPTY_FILE_LIST;
    File fileToBackup = new File(updateFile);
    try {
        expiredBackupFiles = createBackupFile(fileToBackup);
    } catch (Exception ex) {
        log.error("Failed to create a backup for " + fileToBackup.getName(), ex); //$NON-NLS-1$
    }

    try {
        convertSubTree(subTree);
    } catch (Exception err) {
        log.warn("Error converting subtree " + err);
    }

    FileOutputStream ostream = null;
    try {
        ostream = new FileOutputStream(updateFile);
        SaveService.saveTree(subTree, ostream);
        if (fullSave) { // Only update the stored copy of the tree for a full save
            subTree = GuiPackage.getInstance().getTreeModel().getTestPlan(); // refetch, because convertSubTree affects it
            if (isWorkbenchSaveable()) {
                HashTree workbench = GuiPackage.getInstance().getTreeModel().getWorkBench();
                subTree.add(workbench);
            }
            ActionRouter.getInstance()
                    .doActionNow(new ActionEvent(subTree, e.getID(), ActionNames.SUB_TREE_SAVED));
        }

        // delete expired backups : here everything went right so we can
        // proceed to deletion
        for (File expiredBackupFile : expiredBackupFiles) {
            try {
                FileUtils.deleteQuietly(expiredBackupFile);
            } catch (Exception ex) {
                log.warn("Failed to delete backup file " + expiredBackupFile.getName()); //$NON-NLS-1$
            }
        }
    } catch (Throwable ex) {
        log.error("Error saving tree:", ex);
        if (ex instanceof Error) {
            throw (Error) ex;
        }
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        throw new IllegalUserActionException("Couldn't save test plan to file: " + updateFile, ex);
    } finally {
        JOrphanUtils.closeQuietly(ostream);
    }
    GuiPackage.getInstance().updateCurrentGui();
}

From source file:org.broad.igv.ui.action.SetTrackHeightMenuAction.java

/**
 * Method description//  ww  w . j ava  2 s .co  m
 */
final public void doSetTrackHeight() {

    boolean doRefresh = false;
    try {
        JPanel container = new JPanel();
        JLabel trackHeightLabel = new JLabel("Track Height (pixels)");
        JTextField trackHeightField = new JTextField();
        Dimension preferredSize = trackHeightField.getPreferredSize();
        trackHeightField.setPreferredSize(new Dimension(50, (int) preferredSize.getHeight()));
        container.add(trackHeightLabel);
        container.add(trackHeightField);

        int repTrackHeight = getRepresentativeTrackHeight();
        trackHeightField.setText(String.valueOf(repTrackHeight));

        int status = JOptionPane.showConfirmDialog(mainFrame.getMainFrame(), container, "Set Track Height",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);

        if ((status == JOptionPane.CANCEL_OPTION) || (status == JOptionPane.CLOSED_OPTION)) {
            return;
        }

        try {
            int newTrackHeight = Integer.parseInt(trackHeightField.getText().trim());
            IGV.getInstance().setAllTrackHeights(newTrackHeight);
            lastTrackHeight = newTrackHeight;
            doRefresh = true;
        } catch (NumberFormatException numberFormatException) {
            JOptionPane.showMessageDialog(mainFrame.getMainFrame(), "Track height must be an integer number.");
        }

    } finally {

        // Refresh view
        if (doRefresh) {

            // Update the state of the current tracks for drawing purposes

            mainFrame.doRefresh();
        }
        mainFrame.resetStatusMessage();
    }

}

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

public ExternalHyperlinkDialog(WordMLEditor wmlEditor, String sourceFileVFSUrlPath, HyperlinkML hyperlinkML,
        FileNameExtensionFilter fileFilter) {
    super(wmlEditor.getWindowFrame(), true);

    this.sourceFileVFSUrlPath = sourceFileVFSUrlPath;
    this.hyperlinkML = hyperlinkML;
    this.fileFilter = fileFilter;
    this.value = CANCEL_BUTTON_TEXT;
    setTitle("External Hyperlink Setup");

    Object[] options = { OK_BUTTON_TEXT, CANCEL_BUTTON_TEXT };
    Object[] array = { createContentPanel(sourceFileVFSUrlPath, hyperlinkML) };
    this.optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options,
            options[0]);/*from w  ww  . j a  v  a  2 s .com*/

    //Make this dialog display it.
    setContentPane(this.optionPane);

    //Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            /*
             * Instead of directly closing the window, we're going to change
             * the JOptionPane's value property.
             */
            ExternalHyperlinkDialog.this.optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
        }
    });

    //Register an event handler that reacts to option pane state changes.
    this.optionPane.addPropertyChangeListener(this);
}

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

private void handleMessage(final Message msg) {
    try {/*ww w . j  a v  a  2  s.co  m*/
        if ((msg.getJMSCorrelationID() == null
                || msg.getJMSCorrelationID().equals(MainController.this.getUserName()))
                && msg instanceof ObjectMessage) {
            final Object objMessage = ((ObjectMessage) msg).getObject();

            if (objMessage.getClass().equals(ApiMessageImpl.class)) {
                final ApiMessageImpl apiMsg = (ApiMessageImpl) ((ObjectMessage) msg).getObject();
                LOG.info("Handle " + apiMsg);
                Component parent = null;
                if (apiMsg.getReceiverId() != null) {
                    MainFrameTab target = MainFrameTab.getMainFrameTab(apiMsg.getReceiverId());
                    parent = target;
                    if (target != null) {
                        if (apiMsg.getMessage().isOverlay()) {
                            OverlayOptionPane.showMessageDialog(target, apiMsg.getMessage().getMessage(),
                                    apiMsg.getMessage().getTitle(), new OvOpAdapter() {
                                    });
                            return;
                        }
                    } else {
                        LOG.warn(String.format("Receiver with id %s not found!", apiMsg.getReceiverId()));
                    }
                }

                if (parent == null) {
                    parent = Main.getInstance().getMainFrame();
                }
                JOptionPane.showMessageDialog(parent, apiMsg.getMessage().getMessage(),
                        apiMsg.getMessage().getTitle(), JOptionPane.INFORMATION_MESSAGE);
            } else if (objMessage.getClass().equals(RuleNotification.class)) {
                final RuleNotification notification = (RuleNotification) ((ObjectMessage) msg).getObject();
                getNotificationDialog().addMessage(notification);
                switch (notification.getPriority()) {
                case LOW:
                    // just add the message, nothing else.
                    break;
                case NORMAL:
                    getMainFrame().getMessagePanel().startFlashing();
                    break;
                case HIGH:
                    getNotificationDialog().setVisible(true);
                    break;
                default:
                    LOG.warn("Undefined message priority: " + notification.getPriority());
                }
                LOG.info("Handled RuleNotification " + notification.toDescription());
            } else if (objMessage.getClass().equals(CommandMessage.class)) {
                final CommandMessage command = (CommandMessage) ((ObjectMessage) msg).getObject();
                switch (command.getCommand()) {
                case CommandMessage.CMD_SHUTDOWN:
                    getNotificationDialog().addMessage(new RuleNotification(Priority.HIGH,
                            getSpringLocaleDelegate().getMessage("MainController.19",
                                    "Der Client wird auf Anweisung des Administrators in 10 Sekunden beendet."),
                            "Administrator"));
                    getNotificationDialog().setVisible(true);

                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                Thread.sleep(10000);
                            } catch (InterruptedException e) {
                                // do nothing
                            } finally {
                                MainController.this.cmdExit();
                            }
                        }
                    });
                    break;
                }
                LOG.info("Handled CommandMessage " + command);
            } else if (objMessage.getClass().equals(CommandInformationMessage.class)) {
                final CommandInformationMessage command = (CommandInformationMessage) ((ObjectMessage) msg)
                        .getObject();
                switch (command.getCommand()) {
                case CommandInformationMessage.CMD_INFO_SHUTDOWN:
                    Object[] options = { "OK" };
                    int decision = JOptionPane.showOptionDialog(getMainFrame(), command.getInfo(),
                            getSpringLocaleDelegate().getMessage("MainController.17",
                                    "Administrator - Passwort\u00e4nderung"),
                            JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options,
                            options[0]);
                    if (decision == 0 || decision == JOptionPane.CLOSED_OPTION
                            || decision == JOptionPane.NO_OPTION) {
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    Thread.sleep(10000);
                                } catch (InterruptedException e) {
                                    // do nothing
                                } finally {
                                    MainController.this.cmdExit();
                                }
                            }
                        }, "MainController.handleMessage.cmdExit").run();
                    }
                    break;
                }
                LOG.info("Handled CommandInformationMessage " + command);
            }
        } else {
            LOG.warn(getSpringLocaleDelegate().getMessage("MainController.14",
                    "Message of type {0} received, while an ObjectMessage was expected.",
                    msg.getClass().getName()));
        }
    } catch (JMSException ex) {
        LOG.warn("Exception thrown in JMS message listener.", ex);
    }
}

From source file:org.openuat.apps.IPSecConnectorAdmin.java

/**
 * dialog to set up the dongle configuration.
 *///from  ww w.  j  a  va 2  s  . c om
private static Configuration configureDialog(String[] ports, String[] sides, String[] types) {
    JTextField username = new JTextField();
    JComboBox cport = new JComboBox(ports);
    JComboBox csides = new JComboBox(sides);
    JComboBox ctypes = new JComboBox(types);
    int option = JOptionPane.showOptionDialog(null,
            new Object[] { "User Name:", username, "Choose your port", cport,
                    "On which side of your Device is the Dongle plugged into:", csides, " What type of Device:",
                    ctypes, },
            " Relate Dongle Configuration", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null,
            null);
    if ((option == JOptionPane.CLOSED_OPTION) || (option == JOptionPane.CANCEL_OPTION)) {
        System.exit(0);
    }
    Configuration config = new Configuration(cport.getSelectedItem() + "");
    config.setType(ctypes.getSelectedIndex());
    config.setSide(csides.getSelectedIndex());
    config.setUserName(username.getText());
    config.setDeviceType(Configuration.DEVICE_TYPE_DONGLE);
    //      logger.finer(config);
    return config;
}

From source file:org.pgptool.gui.ui.tools.UiUtils.java

/**
 * @param messageType//from  w  ww  . j a  va  2  s  .  c  o m
 *            one of the JOptionPane ERROR_MESSAGE, INFORMATION_MESSAGE,
 *            WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
 */
public static void messageBox(Component parent, String msg, String title, int messageType) {
    Object content = buildMessageContentDependingOnLength(msg);

    if (messageType != JOptionPane.ERROR_MESSAGE) {
        JOptionPane.showMessageDialog(parent, content, title, messageType);
        return;
    }

    Object[] options = { text("action.ok"), text("phrase.saveMsgToFile") };
    if ("action.ok".equals(options[0])) {
        // if app context wasn't started MessageSource wont be available
        options = new String[] { "OK", "Save message to file" };
    }

    int result = JOptionPane.showOptionDialog(parent, content, title, JOptionPane.YES_NO_OPTION, messageType,
            null, options, JOptionPane.YES_OPTION);
    if (result == JOptionPane.YES_OPTION || result == JOptionPane.CLOSED_OPTION) {
        return;
    }

    // Save to file
    saveMessageToFile(parent, msg);
}