Example usage for javax.swing JOptionPane DEFAULT_OPTION

List of usage examples for javax.swing JOptionPane DEFAULT_OPTION

Introduction

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

Prototype

int DEFAULT_OPTION

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

Click Source Link

Document

Type meaning Look and Feel should not supply any options -- only use the options from the JOptionPane.

Usage

From source file:com.pironet.tda.TDA.java

/**
 * close the currently selected dump./*  w w  w. j  a  v a 2s  . c  o  m*/
 */
private void closeCurrentDump() {
    TreePath selPath = tree.getSelectionPath();

    while (selPath != null && !(checkNameFromNode((DefaultMutableTreeNode) selPath.getLastPathComponent(),
            File.separator)
            || checkNameFromNode((DefaultMutableTreeNode) selPath.getLastPathComponent(), 2, File.separator))) {
        selPath = selPath.getParentPath();
    }

    Object[] options = { "Close File", "Cancel close" };

    String fileName = ((DefaultMutableTreeNode) selPath.getLastPathComponent()).getUserObject().toString();
    fileName = fileName.substring(fileName.indexOf(File.separator));

    int selectValue = JOptionPane.showOptionDialog(null,
            "<html><body>Are you sure, you want to close the currently selected dump file<br><b>" + fileName
                    + "</b></body></html>",
            "Confirm closing...", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
            options[0]);

    // if first option "close file" is selected.
    if (selectValue == 0) {
        // remove stuff from the top nodes
        topNodes.remove(selPath.getLastPathComponent());

        if (topNodes.size() == 0) {
            // simply do a reinit, as there isn't anything to display
            removeAll();
            revalidate();

            init(runningAsJConsolePlugin, runningAsVisualVMPlugin);
            getMainMenu().getLongMenuItem().setEnabled(false);
            getMainMenu().getCloseMenuItem().setEnabled(false);
            getMainMenu().getSaveSessionMenuItem().setEnabled(false);
            getMainMenu().getCloseToolBarButton().setEnabled(false);
            getMainMenu().getExpandButton().setEnabled(false);
            getMainMenu().getCollapseButton().setEnabled(false);
            getMainMenu().getFindLRThreadsToolBarButton().setEnabled(false);
            getMainMenu().getCloseAllMenuItem().setEnabled(false);
            getMainMenu().getExpandAllMenuItem().setEnabled(false);
            getMainMenu().getCollapseAllMenuItem().setEnabled(false);

        } else {
            // rebuild jtree
            getMainMenu().getCloseMenuItem().setEnabled(false);
            getMainMenu().getCloseToolBarButton().setEnabled(false);
            createTree();
        }
        revalidate();
    }

}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addService() throws DocumentException {
        // ?  ?  ?     ?,  
        String serviceName = "";
        boolean flag = true;
        while (flag) {
            serviceName = (String) JOptionPane.showInputDialog(this,
                    getLocaleMessage("admin.add_service_dialog.title"),
                    getLocaleMessage("admin.add_service_dialog.caption"), 3, null, null, serviceName);
            if (serviceName == null) {
                return;
            }//from   www  . j  av a  2  s. co m
            if ("".equals(serviceName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err1.title"),
                        getLocaleMessage("admin.add_service_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (QServiceTree.getInstance().hasByName(serviceName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err2.title"),
                        getLocaleMessage("admin.add_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (serviceName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err3.title"),
                        getLocaleMessage("admin.add_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (serviceName.length() > 2001) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err4.title"),
                        getLocaleMessage("admin.add_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        //   ?     
        final QService newService = new QService();
        newService.setName(serviceName);
        newService.setDescription(serviceName);
        newService.setStatus(1);
        newService.setSoundTemplate("021111");
        newService.setAdvanceTimePeriod(60);
        newService.setCalendar(QCalendarList.getInstance().getById(1));
        if (QScheduleList.getInstance().getSize() != 0) {
            newService.setSchedule(QScheduleList.getInstance().getElementAt(0));
        }
        newService.setButtonText(
                "<html><b><p align=center><span style='font-size:20.0pt;color:red'>" + serviceName + "</span></b>");
        //? 
        newService.setPrefix("A");
        QServiceTree.sailToStorm(QServiceTree.getInstance().getRoot(), (TreeNode service) -> {
            if (service.isLeaf()) {
                String pr = ((QService) service).getPrefix();
                if (!pr.isEmpty()) {
                    if (pr.substring(pr.length() - 1).compareToIgnoreCase(
                            newService.getPrefix().substring(newService.getPrefix().length() - 1)) >= 0) {
                        newService.setPrefix(
                                String.valueOf((char) (pr.substring(pr.length() - 1).charAt(0) + 1)).toUpperCase());
                    }
                }
            }
        });

        final QService parentService = (QService) treeServices.getLastSelectedPathComponent();
        QServiceTree.getInstance().insertNodeInto(newService, parentService, parentService.getChildCount());
        final TreeNode[] nodes = QServiceTree.getInstance().getPathToRoot(newService);
        final TreePath path = new TreePath(nodes);
        treeServices.scrollPathToVisible(path);
        treeServices.setSelectionPath(path);
        // ? ?   ?  ?  ?? ?  , ..  ? 
        deleteServiceFromUsers(parentService);

        QLog.l().logger().debug(" ? \"" + serviceName + "\"   \""
                + parentService.getName() + "\"");
    }

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openAnalyseDialog(final int chip) {
    JTextField optionsField = new JTextField();
    JTextField destinationField = new JTextField();

    // compute and try default names for options file.
    // In order : <firmware>.dfr.txt , <firmware>.txt , dfr.txt (or the same for dtx)
    File optionsFile = new File(imageFile[chip].getParentFile(),
            FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath())
                    + ((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt"));
    if (!optionsFile.exists()) {
        optionsFile = new File(imageFile[chip].getParentFile(),
                FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".txt");
        if (!optionsFile.exists()) {
            optionsFile = new File(imageFile[chip].getParentFile(),
                    ((chip == Constants.CHIP_FR) ? "dfr.txt" : "dtx.txt"));
            if (!optionsFile.exists()) {
                optionsFile = null;//from   ww  w . j  av a2s. co  m
            }
        }
    }
    if (optionsFile != null) {
        optionsField.setText(optionsFile.getAbsolutePath());
    }

    // compute default name for output
    File outputFile = new File(imageFile[chip].getParentFile(),
            FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".asm");
    destinationField.setText(outputFile.getAbsolutePath());

    final JCheckBox writeOutputCheckbox = new JCheckBox("Write disassembly to file");

    final FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file",
            destinationField, false);
    destinationFileSelectionPanel.setFileFilter(".asm", "Assembly language file (*.asm)");
    writeOutputCheckbox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean writeToFile = writeOutputCheckbox.isSelected();
            destinationFileSelectionPanel.setEnabled(writeToFile);
            prefs.setWriteDisassemblyToFile(chip, writeToFile);
        }
    });

    writeOutputCheckbox.setSelected(prefs.isWriteDisassemblyToFile(chip));
    destinationFileSelectionPanel.setEnabled(prefs.isWriteDisassemblyToFile(chip));

    FileSelectionPanel fileSelectionPanel = new FileSelectionPanel(
            (chip == Constants.CHIP_FR) ? "Dfr options file" : "Dtx options file", optionsField, false);
    fileSelectionPanel.setFileFilter((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt",
            (chip == Constants.CHIP_FR) ? "Dfr options file (*.dfr.txt)" : "Dtx options file (*.dtx.txt)");
    final JComponent[] inputs = new JComponent[] {
            //new FileSelectionPanel("Source file", sourceFile, false, dependencies),
            fileSelectionPanel, writeOutputCheckbox, destinationFileSelectionPanel,
            makeOutputOptionCheckBox(chip, OutputOption.STRUCTURE, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.ORDINAL, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.PARAMETERS, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.INT40, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.MEMORY, prefs.getOutputOptions(chip), true),
            new JLabel("(hover over the options for help. See also 'Tools/Options/Disassembler output')",
                    SwingConstants.CENTER) };

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose analyse options",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        String outputFilename = writeOutputCheckbox.isSelected() ? destinationField.getText() : null;
        boolean cancel = false;
        if (outputFilename != null) {
            if (new File(outputFilename).exists()) {
                if (JOptionPane.showConfirmDialog(this,
                        "File '" + outputFilename + "' already exists.\nDo you really want to overwrite it ?",
                        "File exists", JOptionPane.YES_NO_OPTION,
                        JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                    cancel = true;
                }
            }
        }
        if (!cancel) {
            AnalyseProgressDialog analyseProgressDialog = new AnalyseProgressDialog(this,
                    framework.getPlatform(chip).getMemory());
            analyseProgressDialog.startBackgroundAnalysis(chip, optionsField.getText(), outputFilename);
            analyseProgressDialog.setVisible(true);
        }
    }
}

From source file:com.pironet.tda.TDA.java

/**
 * close all open dumps/*from www  .j  a  v  a  2 s . c om*/
 */
private void closeAllDumps() {
    Object[] options = { "Close all", "Cancel close" };

    int selectValue = JOptionPane.showOptionDialog(null,
            "<html><body>Are you sure, you want to close all open dump files", "Confirm closing...",
            JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);

    // if first option "close file" is selected.
    if (selectValue == 0) {
        // remove stuff from the top nodes
        topNodes = new Vector<>();

        // simply do a re-init, as there is anything to display
        resetMainPanel();
    }
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void renameService() {
        final QService service = (QService) treeServices.getLastSelectedPathComponent();
        if (service != null) {
            String serviceName = service.getName();
            boolean flag = true;
            while (flag) {
                serviceName = (String) JOptionPane.showInputDialog(this,
                        getLocaleMessage("admin.rename_service_dialog.title"),
                        getLocaleMessage("admin.rename_service_dialog.caption"), 3, null, null, serviceName);
                if (serviceName == null) {
                    return;
                }//from   www .j  a v a  2 s .  com
                if ("".equals(serviceName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err1.title"),
                            getLocaleMessage("admin.rename_service_dialog.err1.caption"),
                            JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
                } else if (QServiceTree.getInstance().hasByName(serviceName)) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err2.title"),
                            getLocaleMessage("admin.rename_service_dialog.err2.caption"),
                            JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
                } else if (serviceName.indexOf('\"') != -1) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err3.title"),
                            getLocaleMessage("admin.rename_service_dialog.err3.caption"),
                            JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
                } else if (serviceName.length() > 2001) {
                    JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err4.title"),
                            getLocaleMessage("admin.rename_service_dialog.err4.caption"),
                            JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
                } else {
                    flag = false;
                }
            }
            service.setName(serviceName);
        }
    }

From source file:Form.Principal.java

private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed
    try {/*  w  w  w  . j av  a 2s . co m*/
        String Comando = null;
        if (jTextField12.getText().equalsIgnoreCase("") || jTextField13.getText().equalsIgnoreCase("")
                || jTextField14.getText().equalsIgnoreCase("") || jTextField15.getText().equalsIgnoreCase("")
                || jTextField18.getText().equalsIgnoreCase("") || jTextField17.getText().equalsIgnoreCase("")
                || jTextField16.getText().equalsIgnoreCase("") || jTextField4.getText().equalsIgnoreCase("")) {
            Object[] options = { "Aceptar" };
            JOptionPane.showOptionDialog(null, "Datos incompletos", "Aviso", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]);
        } else {
            Variables.RFC = jTextField12.getText();
            Variables.NombreCliente = jTextField14.getText();
            Variables.Direccion = jTextField13.getText();
            Variables.Estado = jTextField15.getText();
            Variables.municipio = jTextField17.getText();
            Variables.delegacion = jTextField18.getText();
            Variables.Correo = jTextField4.getText();
            Variables.codpostal = jTextField16.getText();

            Comando = "UPDATE cliente SET NombreCliente='" + jTextField14.getText() + "',Direccion='"
                    + jTextField13.getText() + "',Estado='" + jTextField15.getText() + "',Municipio='"
                    + jTextField17.getText() + "',Localidad='" + jTextField18.getText() + "',codPostal='"
                    + jTextField16.getText() + "',correo='" + jTextField4.getText() + "',RFC='"
                    + jTextField12.getText() + "' WHERE idCliente=" + id + ";";
            Funcion.Update(st, Comando);
            Variables.Comentario = jTextField21.getText();

            if (editarcliente2 == false)
                botonfalse();
            else {
                jTextField12.setText("");
                jTextField14.setText("");
                jTextField13.setText("");
                jTextField15.setText("");
                jTextField17.setText("");
                jTextField18.setText("");
                jTextField16.setText("");
                jTextField4.setText("");
                jTextField21.setText("");
                EditarClientes.remove(scrollcuadro);
                jPanel9.setVisible(false);
                EnviarSAT1.setVisible(true);
                jButton18.setVisible(true);
                jButton15.setVisible(true);
                scrollcuadro.setVisible(true);
                jButtonSave.setVisible(false);
                jButton16.setVisible(false);
                jPanel14.setVisible(false);
                CrearPanelPDF();
            }
            editarcliente2 = false;
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e);
        System.out.print(e.getMessage());
        e.printStackTrace();
    }

}

From source file:de.dal33t.powerfolder.Controller.java

/**
 * Called if controller has detected a already running instance
 *///from  w w  w  . j  a  v a  2s . c om
private void alreadyRunningCheck() {
    Component parent = null;
    if (isUIOpen()) {
        parent = uiController.getMainFrame().getUIComponent();
    }
    if (!isStartMinimized() && isUIEnabled() && !commandLine.hasOption('z')) {
        Object[] options = { Translation.getTranslation("dialog.already_running.show_button") };
        int exitOption = 0;
        if (verbose) {
            options = new Object[] { Translation.getTranslation("dialog.already_running.start_button"),
                    Translation.getTranslation("dialog.already_running.exit_button") };
            exitOption = 1;
        }
        if (JOptionPane.showOptionDialog(parent, Translation.getTranslation("dialog.already_running.warning"),
                Translation.getTranslation("dialog.already_running.title"), JOptionPane.DEFAULT_OPTION,
                JOptionPane.INFORMATION_MESSAGE, null, options, options[0]) == exitOption) { // exit pressed
                                                                                                                                                                                                                                                                                            // Try to bring existing instance to the foreground.
            RemoteCommandManager.sendCommand(RemoteCommandManager.SHOW_UI);
            exit(1);
        } else {
            exit(1);
        }
    } else {
        // If no gui show error but start anyways
        logWarning("PowerFolder already running");
    }
}

From source file:de.dal33t.powerfolder.Controller.java

private void fatalStartError(String message) {
    Component parent = null;/*from  w  ww  .j  a v a  2s.c o  m*/
    if (isUIOpen()) {
        parent = uiController.getMainFrame().getUIComponent();
    }
    if (isUIEnabled()) {
        Object[] options = { Translation.getTranslation("dialog.already_running.exit_button") };
        JOptionPane.showOptionDialog(parent, message, Translation.getTranslation("dialog.fatal_error.title"),
                JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]);
    } else {
        logSevere(message);
    }
    exit(1);
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

@Action
    public void addInfoItem() {
        // ?    ?     ?,  
        String infoName = getLocaleMessage("admin.add_info_dialog.info");
        boolean flag = true;
        while (flag) {
            infoName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_info_dialog.title"),
                    getLocaleMessage("admin.add_info_dialog.caption"), 3, null, null, infoName);
            if (infoName == null) {
                return;
            }/*  w  ww. j av  a 2 s.co m*/
            if ("".equals(infoName)) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_info_dialog.err1.title"),
                        getLocaleMessage("admin.add_info_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (infoName.indexOf('\"') != -1) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_info_dialog.err2.title"),
                        getLocaleMessage("admin.add_info_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else if (infoName.length() > 100) {
                JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_info_dialog.err3.title"),
                        getLocaleMessage("admin.add_info_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION,
                        JOptionPane.ERROR_MESSAGE);
            } else {
                flag = false;
            }
        }
        //   ?     
        final QInfoItem newItem = new QInfoItem();
        newItem.setName(infoName);
        newItem.setHTMLText(
                "<html><b><p align=center><span style='font-size:20.0pt;color:green'>" + infoName + "</span></b>");
        newItem.setTextPrint("");
        final QInfoItem parentItem = (QInfoItem) treeInfo.getLastSelectedPathComponent();
        ((QInfoTree) treeInfo.getModel()).insertNodeInto(newItem, parentItem, parentItem.getChildCount());
        final TreeNode[] nodes = ((QInfoTree) treeInfo.getModel()).getPathToRoot(newItem);
        final TreePath path = new TreePath(nodes);
        treeInfo.scrollPathToVisible(path);
        treeInfo.setSelectionPath(path);
        textFieldInfoItemName.setEnabled(true);
        //textPaneInfoItem.setEnabled(true);
        //textPaneInfoPrint.setEnabled(true);

        QLog.l().logger().debug("  \"" + infoName + "\"   \""
                + parentItem.getName() + "\"");
    }

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openUIOptionsDialog() {
    JPanel options = new JPanel(new GridLayout(0, 1));
    options.setName("User Interface");
    // Button size
    ActionListener buttonSizeRadioListener = new ActionListener() {
        @Override//from  w  w  w .  java2 s . c om
        public void actionPerformed(ActionEvent e) {
            prefs.setButtonSize(e.getActionCommand());
        }
    };
    JRadioButton small = new JRadioButton("Small");
    small.setActionCommand(BUTTON_SIZE_SMALL);
    small.addActionListener(buttonSizeRadioListener);
    if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize()))
        small.setSelected(true);
    JRadioButton medium = new JRadioButton("Medium");
    medium.setActionCommand(BUTTON_SIZE_MEDIUM);
    medium.addActionListener(buttonSizeRadioListener);
    if (BUTTON_SIZE_MEDIUM.equals(prefs.getButtonSize()))
        medium.setSelected(true);
    JRadioButton large = new JRadioButton("Large");
    large.setActionCommand(BUTTON_SIZE_LARGE);
    large.addActionListener(buttonSizeRadioListener);
    if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize()))
        large.setSelected(true);

    ButtonGroup group = new ButtonGroup();
    group.add(small);
    group.add(medium);
    group.add(large);

    // Close windows on stop
    final JCheckBox closeAllWindowsOnStopCheckBox = new JCheckBox("Close all windows on Stop");
    closeAllWindowsOnStopCheckBox.setSelected(prefs.isCloseAllWindowsOnStop());

    // Refresh interval
    JPanel refreshIntervalPanel = new JPanel();
    final JTextField refreshIntervalField = new JTextField(5);
    refreshIntervalPanel.add(new JLabel("Refresh interval for cpu, screen, etc. (ms):"));

    refreshIntervalField.setText("" + prefs.getRefreshIntervalMs());
    refreshIntervalPanel.add(refreshIntervalField);

    // Setup panel
    options.add(new JLabel("Button size :"));
    options.add(small);
    options.add(medium);
    options.add(large);
    options.add(closeAllWindowsOnStopCheckBox);
    options.add(refreshIntervalPanel);
    options.add(new JLabel("Larger value greatly increases emulation speed"));

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, options, "Preferences",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        // save
        prefs.setButtonSize(group.getSelection().getActionCommand());
        prefs.setCloseAllWindowsOnStop(closeAllWindowsOnStopCheckBox.isSelected());
        int refreshIntervalMs = 0;
        try {
            refreshIntervalMs = Integer.parseInt(refreshIntervalField.getText());
        } catch (NumberFormatException e) {
            // noop
        }
        refreshIntervalMs = Math.max(Math.min(refreshIntervalMs, 10000), 10);
        prefs.setRefreshIntervalMs(refreshIntervalMs);
        applyPrefsToUI();
    }
}