Example usage for javax.swing JOptionPane YES_NO_CANCEL_OPTION

List of usage examples for javax.swing JOptionPane YES_NO_CANCEL_OPTION

Introduction

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

Prototype

int YES_NO_CANCEL_OPTION

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

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:de.dakror.virtualhub.client.dialog.ChooseCatalogDialog.java

public static void show(ClientFrame frame, final JSONArray data) {
    final JDialog dialog = new JDialog(frame, "Katalog whlen", true);
    dialog.setSize(400, 300);//from w w w  .  ja v  a 2  s. c  o m
    dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            Client.currentClient.disconnect();
            System.exit(0);
        }
    });

    JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    dialog.setContentPane(contentPane);
    DefaultListModel dlm = new DefaultListModel();
    for (int i = 0; i < data.length(); i++) {
        try {
            dlm.addElement(data.getJSONObject(i).getString("name"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    final JList catalogs = new JList(dlm);
    catalogs.setDragEnabled(false);
    catalogs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane jsp = new JScrollPane(catalogs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jsp.setPreferredSize(new Dimension(396, 200));
    contentPane.add(jsp);

    JPanel mods = new JPanel(new GridLayout(1, 2));
    mods.setPreferredSize(new Dimension(50, 22));
    mods.add(new JButton(new AbstractAction("+") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            String name = JOptionPane.showInputDialog(dialog,
                    "Bitte geben Sie den Namen des neuen Katalogs ein.", "Katalog hinzufgen",
                    JOptionPane.PLAIN_MESSAGE);
            if (name != null && name.length() > 0) {
                DefaultListModel dlm = (DefaultListModel) catalogs.getModel();
                for (int i = 0; i < dlm.getSize(); i++) {
                    if (dlm.get(i).toString().equals(name)) {
                        JOptionPane.showMessageDialog(dialog,
                                "Es existert bereits ein Katalog mit diesem Namen!",
                                "Katalog bereits vorhanden!", JOptionPane.ERROR_MESSAGE);
                        actionPerformed(e);
                        return;
                    }
                }

                try {
                    dlm.addElement(name);
                    JSONObject o = new JSONObject();
                    o.put("name", name);
                    o.put("sources", new JSONArray());
                    o.put("tags", new JSONArray());
                    data.put(o);
                    Client.currentClient.sendPacket(new Packet0Catalogs(data));
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }));
    mods.add(new JButton(new AbstractAction("-") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (catalogs.getSelectedIndex() != -1) {
                if (JOptionPane.showConfirmDialog(dialog,
                        "Sind Sie sicher, dass Sie diesen\r\nKatalog unwiderruflich lschen wollen?",
                        "Katalog lschen", JOptionPane.YES_NO_CANCEL_OPTION,
                        JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
                    DefaultListModel dlm = (DefaultListModel) catalogs.getModel();
                    data.remove(catalogs.getSelectedIndex());
                    dlm.remove(catalogs.getSelectedIndex());
                    try {
                        Client.currentClient.sendPacket(new Packet0Catalogs(data));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    }));

    contentPane.add(mods);

    JLabel l = new JLabel("");
    l.setPreferredSize(new Dimension(396, 14));
    contentPane.add(l);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    sep.setPreferredSize(new Dimension(396, 10));
    contentPane.add(sep);

    JPanel buttons = new JPanel(new GridLayout(1, 2));
    buttons.setPreferredSize(new Dimension(396, 22));
    buttons.add(new JButton(new AbstractAction("Abbrechen") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            Client.currentClient.disconnect();
            System.exit(0);
        }
    }));
    buttons.add(new JButton(new AbstractAction("Katalog whlen") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (catalogs.getSelectedIndex() != -1) {
                try {
                    Client.currentClient
                            .setCatalog(new Catalog(data.getJSONObject(catalogs.getSelectedIndex())));
                    Client.currentClient.frame.setTitle("- " + Client.currentClient.getCatalog().getName());
                    dialog.dispose();
                } catch (JSONException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }));

    dialog.add(buttons);

    dialog.setLocationRelativeTo(frame);
    dialog.setResizable(false);
    dialog.setVisible(true);
}

From source file:com.stefanbrenner.droplet.ui.DevicePanel.java

/**
 * Create the panel./*from w  w  w.  ja  v  a  2 s. c  o m*/
 */
public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) {

    this.parent = parent;

    setDevice(device);

    setLayout(new BorderLayout(0, 5));
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    setBackground(DropletColors.getBackgroundColor(device));

    BeanAdapter<T> adapter = new BeanAdapter<T>(device, true);

    // device name textfield
    txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME));
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setColumns(1);
    txtName.setToolTipText(device.getName());
    adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            txtName.setToolTipText(device.getName());
        }
    });
    add(txtName, BorderLayout.NORTH);

    // actions panel with scroll pane
    actionsPanel = new JPanel();
    actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS));
    actionsPanel.setBackground(getBackground());

    JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // resize vertical scrollbar
    scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    SwingUtilities.updateComponentTreeUI(scrollPane);
    // we need no border
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);

    {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));

        createAddButton(panel);

        // remove button
        JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$
        btnRemove.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent action) {
                int retVal = JOptionPane.showConfirmDialog(DevicePanel.this,
                        Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retVal == JOptionPane.YES_OPTION) {
                    droplet.removeDevice(device);
                }
            }
        });
        btnRemove.setFocusable(false);
        panel.add(btnRemove);

        add(panel, BorderLayout.SOUTH);
    }

}

From source file:com.codedx.burp.security.InvalidCertificateDialogStrategy.java

@Override
public CertificateAcceptance checkAcceptance(Certificate genericCert, CertificateException certError) {
    if (genericCert instanceof X509Certificate && defaultHostVerifier instanceof DefaultHostnameVerifier) {
        X509Certificate cert = (X509Certificate) genericCert;
        DefaultHostnameVerifier verifier = (DefaultHostnameVerifier) defaultHostVerifier;

        JPanel message = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = 2;/*  w  w  w.ja va  2  s .  com*/
        gbc.insets = new Insets(0, 0, 10, 0);
        gbc.anchor = GridBagConstraints.WEST;
        message.add(
                new JLabel("Unable to establish a secure connection because the certificate is not trusted"),
                gbc);

        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.insets = new Insets(2, 0, 2, 0);
        gbc.anchor = GridBagConstraints.WEST;

        JLabel issuer = new JLabel("Issuer: ");
        Font defaultFont = issuer.getFont();
        Font bold = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize());
        issuer.setFont(bold);

        message.add(issuer, gbc);
        gbc.gridx = 1;
        message.add(new JLabel(cert.getIssuerDN().toString()), gbc);

        try {
            JLabel fingerprint = new JLabel("Thumbprint: ");
            fingerprint.setFont(bold);
            gbc.gridx = 0;
            gbc.gridy += 1;
            message.add(fingerprint, gbc);

            gbc.gridx = 1;
            message.add(new JLabel(toHexString(getSHA1(cert.getEncoded()), " ")), gbc);
        } catch (CertificateEncodingException e) {
            // this shouldn't actually ever happen
        }

        try {
            verifier.verify(host, cert);
        } catch (SSLException e) {
            String cn = getCN(cert);

            JLabel mismatch = new JLabel("Host Mismatch: ");
            mismatch.setFont(bold);
            gbc.gridx = 0;
            gbc.gridy += 1;
            message.add(mismatch, gbc);

            String msg;
            if (cn != null) {
                msg = String.format("Expected '%s', but the certificate is for '%s'.", host, cn);
            } else {
                msg = e.getMessage();
            }

            gbc.gridx = 1;
            message.add(new JLabel(msg), gbc);
        }

        // Open the dialog, and return its result
        int choice = JOptionPane.showOptionDialog(burpExtender.getUiComponent(), message, dialogTitle,
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, dialogButtons, null);
        switch (choice) {
        case (0):
            return CertificateAcceptance.REJECT;
        case (1):
            return CertificateAcceptance.ACCEPT_TEMPORARILY;
        case (2):
            return CertificateAcceptance.ACCEPT_PERMANENTLY;
        }
    }
    return CertificateAcceptance.REJECT;
}

From source file:br.gov.serpro.cert.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
 *//*from  w  w  w.j av a  2 s.co  m*/
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isInfoEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.info(" Server certificate " + (c + 1) + ":");
            LOG.info("  Subject DN: " + cert.getSubjectDN());
            LOG.info("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.info("  Valid from: " + cert.getNotBefore());
            LOG.info("  Valid until: " + cert.getNotAfter());
            LOG.info("  Issuer: " + cert.getIssuerDN());
        }
    }
    // TODO: Implementar uma caixa de dilogo que pergunta para o usurio se ele quer aceitar o certificado do site
    // Implementado com try/catch usando JOptionPanel

    try {
        defaultTrustManager.checkServerTrusted(certificates, authType);
    } catch (CertificateException e) {
        //Object[] options = {"Aceitar Certificado", "Aceitar Permanentemente", "Cancelar"};
        Object[] options = { "Aceitar Certificado", "Cancelar" };
        switch (JOptionPane.showOptionDialog(null,
                "Falha na validao do seguinte certificado:\n"
                        + certificates[0].getSubjectX500Principal().getName(),
                "\nO que voc quer fazer?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
                options, options[0])) {
        case 2:
            // Rejeita certificado!
            throw e;
        case 1:
            // Aceita certificado permanentemente
            // TODO: Adicionar cdigo para inserir o certificado como um certificado confivel
            break;
        // Aceita certificado para esta sesso

        }
    }
}

From source file:modmanager.MainWindow.java

private void selectSkyrimDirectory(boolean force) {
    skyrimDirectoryChooser.setDialogTitle("Select Skyrim folder");
    skyrimDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    boolean chosen = false;

    while (skyrimDirectoryChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        /**/*from w ww. j  a va2 s .  co  m*/
         * Use a while loop to check for valid skyrim installation ...
         */
        if (!FileUtils.getFile(skyrimDirectoryChooser.getSelectedFile(), "TESV.exe").exists()) {
            int result = JOptionPane.showConfirmDialog(this,
                    "It seems that this directory does not contain Skyrim!\nContinue anyways?",
                    "Invalid Skyrim directory", JOptionPane.YES_NO_CANCEL_OPTION);

            if (result == JOptionPane.CANCEL_OPTION) {
                break;
            }
            if (result == JOptionPane.YES_OPTION) {
                chosen = true;
                break;
            }
        } else {
            chosen = true;
            break;
        }
    }

    if (force && !chosen) {
        System.exit(0);
    }

    modifications.setSkyrimDirectory(skyrimDirectoryChooser.getSelectedFile());
}

From source file:edu.ku.brc.specify.tasks.InteractionsProcessor.java

/**
 * Asks where the source of the Loan Preps should come from.
 * @return the source enum/*ww  w.  j a  v a2s. c om*/
 */
protected ASK_TYPE askSourceOfPreps(final boolean hasInfoReqs, final boolean hasColObjRS,
        final T currPrepProvider) {
    String label;
    if (hasInfoReqs && hasColObjRS) {
        label = getResourceString("NEW_INTER_USE_RS_IR");

    } else if (hasInfoReqs) {
        label = getResourceString("NEW_INTER_USE_IR");
    } else {
        label = getResourceString("NEW_INTER_USE_RS");
    }

    boolean isForAcc = isFor == forAcc;
    Object[] options = new Object[!isForAcc
            || (isForAcc && ((!hasInfoReqs && !hasColObjRS) || currPrepProvider != null)) ? 2 : 3];
    Integer dosOpt = null;
    Integer rsOpt = null;
    Integer noneOpt = null;
    if (!isForAcc || currPrepProvider != null) {
        options[0] = label;
        options[1] = getResourceString("NEW_INTER_ENTER_CATNUM");
        rsOpt = JOptionPane.YES_OPTION;
        dosOpt = JOptionPane.NO_OPTION;
    } else {
        if (options.length == 2) {
            options[0] = getResourceString("NEW_INTER_ENTER_CATNUM");
            options[1] = getResourceString("NEW_INTER_EMPTY");
            dosOpt = JOptionPane.YES_OPTION;
            noneOpt = JOptionPane.NO_OPTION;
        } else {
            options[0] = label;
            options[1] = getResourceString("NEW_INTER_ENTER_CATNUM");
            options[2] = getResourceString("NEW_INTER_EMPTY");
            rsOpt = JOptionPane.YES_OPTION;
            dosOpt = JOptionPane.NO_OPTION;
            noneOpt = JOptionPane.CANCEL_OPTION;
        }
    }

    int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
            getResourceString("NEW_INTER_CHOOSE_RSOPT"), getResourceString("NEW_INTER_CHOOSE_RSOPT_TITLE"),
            JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
    if (userChoice == dosOpt) {
        return ASK_TYPE.EnterDataObjs;
    } else if (rsOpt != null && userChoice == rsOpt) {
        return ASK_TYPE.ChooseRS;
    } else if (noneOpt != null && userChoice == noneOpt) {
        return ASK_TYPE.None;
    }

    return ASK_TYPE.Cancel;
}

From source file:net.pms.newgui.LanguageSelection.java

public void show() {
    if (PMS.isHeadless()) {
        // Can only get here during startup in headless mode, there's no way to trigger it from the GUI
        LOGGER.info(/*from   w w  w  .j  a va2 s  .  c  o m*/
                "No language is configured and the language selection dialog is unavailable in headless mode");
        LOGGER.info("Defaulting to OS locale {}", Locale.getDefault().getDisplayName());
        PMS.setLocale(Locale.getDefault());
    } else {
        pane = new JOptionPane(buildComponent(), JOptionPane.PLAIN_MESSAGE, JOptionPane.NO_OPTION, null,
                new JButton[] { applyButton, selectButton }, selectButton);
        pane.setComponentOrientation(ComponentOrientation.getOrientation(locale));
        dialog = pane.createDialog(parentComponent, PMS.NAME);
        dialog.setModalityType(ModalityType.APPLICATION_MODAL);
        dialog.setIconImage(LooksFrame.readImageIcon("icon-32.png").getImage());
        setStrings();
        dialog.pack();
        dialog.setLocationRelativeTo(parentComponent);
        dialog.setVisible(true);
        dialog.dispose();

        if (pane.getValue() == null) {
            aborted = true;
        } else if (!((String) pane.getValue()).equals(PMS.getConfiguration().getLanguageRawString())) {
            if (rebootOnChange) {
                int response = JOptionPane.showConfirmDialog(parentComponent,
                        String.format(buildString("Dialog.Restart", true), PMS.NAME, PMS.NAME),
                        buildString("Dialog.Confirm"), JOptionPane.YES_NO_CANCEL_OPTION);
                if (response != JOptionPane.CANCEL_OPTION) {
                    PMS.getConfiguration().setLanguage((String) pane.getValue());
                    if (response == JOptionPane.YES_OPTION) {
                        try {
                            PMS.getConfiguration().save();
                        } catch (ConfigurationException e) {
                            LOGGER.error("Error while saving configuration: {}", e.getMessage());
                            LOGGER.trace("", e);
                        }
                        ProcessUtil.reboot();
                    }
                }
            } else {
                PMS.getConfiguration().setLanguage((String) pane.getValue());
            }
        }
    }
}

From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.KgmlEdMain.java

/**
 * Constructs a new instance of the editor.
 *///from  w  w  w  .  j ava 2  s.co  m
public KgmlEdMain(final boolean showMainFrame, String applicationName, String[] args) {
    // URL config,
    final ThreadSafeOptions tso = new ThreadSafeOptions();
    SplashScreenInterface splashScreen = new DBEsplashScreen(applicationName, "", new Runnable() {
        public void run() {
            if (showMainFrame) {
                ClassLoader cl = this.getClass().getClassLoader();
                String path = this.getClass().getPackage().getName().replace('.', '/');
                ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png"));
                final MainFrame mainFrame = MainFrame.getInstance();
                mainFrame.setIconImage(icon.getImage());

                Thread t = new Thread(new Runnable() {
                    public void run() {
                        long waitTime = 0;
                        long start = System.currentTimeMillis();
                        do {
                            if (ErrorMsg.getAppLoadingStatus() == ApplicationStatus.ADDONS_LOADED)
                                break;
                            try {
                                Thread.sleep(50);
                            } catch (InterruptedException e) {
                            }
                            waitTime = System.currentTimeMillis() - start;
                        } while (waitTime < 2000);
                        SplashScreenInterface ss = (SplashScreenInterface) tso.getParam(0, null);
                        ss.setVisible(false);
                        mainFrame.setVisible(true);
                    }
                }, "wait for add-on initialization");
                t.start();
            }

        }
    });
    tso.setParam(0, splashScreen);

    ClassLoader cl = this.getClass().getClassLoader();
    String path = this.getClass().getPackage().getName().replace('.', '/');
    ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png"));
    ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage());

    splashScreen.setVisible(true);
    GravistoMainHelper.createApplicationSettingsFolder(splashScreen);
    if (!(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted")).exists()
            && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected")).exists()) {

        ReleaseInfo.setIsFirstRun(true);

        splashScreen.setVisible(false);
        splashScreen.setText("Request KEGG License Status");
        JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While "
                + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>"
                + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>"
                + "For using " + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " you need also be aware of information about licenses and conditions for<br>"
                + "usage, listed at the program info dialog and the " + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " website (" + ReleaseInfo.getAppWebURL() + ").<br><br>"
                + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " does not distribute information from KEGG but contains functionality for the online-access to  information from KEGG wesite.<br><br>"
                + "<b>Before these functions are available to you, you should  carefully read the following license information<br>"
                + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>"
                + "all other features of this application are still available and fully working.",
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.INFORMATION_MESSAGE);

        JOptionPane.showMessageDialog(null,
                "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(),
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.INFORMATION_MESSAGE);

        int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?",
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (result == JOptionPane.YES_OPTION) {
            try {
                new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted").createNewFile();
            } catch (IOException e) {
                ErrorMsg.addErrorMessage(e);
            }
        }
        if (result == JOptionPane.NO_OPTION) {
            try {
                new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected").createNewFile();
            } catch (IOException e) {
                ErrorMsg.addErrorMessage(e);
            }
        }
        if (result == JOptionPane.CANCEL_OPTION) {
            JOptionPane.showMessageDialog(null, "Startup aborted.",
                    DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                    JOptionPane.INFORMATION_MESSAGE);
            System.exit(0);
        }
        splashScreen.setVisible(true);
    }

    GravistoMainHelper.initApplicationExt(args, splashScreen, cl, null, null);

}

From source file:org.fhaes.FHRecorder.FireHistoryRecorder.java

/**
 * Closes the dialog but only after running necessary checks
 * to ensure user doesn't inadvertently loose data 
 * /*from w ww.j  a  v  a 2 s. co m*/
 */
private void closeAfterRunningChecks() {
    if (Controller.isModified()) {
        Object[] options = { "Save", "Close without saving", "Cancel" };
        int n = JOptionPane.showOptionDialog(Controller.thePrimaryWindow,
                "Save changes to file before closing?", "Confirm", JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[2]);

        if (n == JOptionPane.YES_OPTION) {
            Controller.save();
            setVisible(false);
        } else if (n == JOptionPane.NO_OPTION) {
            Controller.setIsModified(false);
            Controller.setIsChangedSinceOpened(false);
            setVisible(false);
        } else if (n == JOptionPane.CANCEL_OPTION) {
            return;
        }

    }

    setVisible(false);
}

From source file:net.sf.profiler4j.console.Console.java

public void disconnect() {
    if (!client.isConnected()) {
        return;/*ww  w . j  av  a  2  s .c  o  m*/
    }
    int ret = JOptionPane.showConfirmDialog(mainFrame,
            "Do you want to undo any changes made to classes before\n" + "you disconnect?\n\n"
                    + "(This requires some time to complete but leaves\n"
                    + "the remote JVM running at 100% of the original speed)",
            "Disconnection", JOptionPane.YES_NO_CANCEL_OPTION);
    if (ret == JOptionPane.CANCEL_OPTION) {
        return;
    }
    final boolean undoChanges = ret == JOptionPane.YES_OPTION;
    LongTask t = new LongTask() {
        public void executeInBackground() throws Exception {
            if (undoChanges) {
                setTaskMessage("Undoing changes to classes...");
                client.restoreClasses(new ProgressCallback() {
                    private int max;

                    public void operationStarted(int amount) {
                        max = amount;
                        update(0);
                    }

                    public void update(int value) {
                        setTaskProgress((value * 100) / max);
                        setTaskMessage("Undoing changes to classes... (class " + value + " of " + max + ")");
                    }
                });
            }
        };
    };
    runInBackground(t);

    memoryPanelTimer.stop();
    sendEvent(AppEventType.TO_DISCONNECT);

    try {
        client.disconnect();
    } catch (ClientException e) {
        error("Connection was close with error: (" + e.getMessage() + ")", e);
    }

    sendEvent(AppEventType.DISCONNECTED);
}