Example usage for javax.swing JOptionPane OK_CANCEL_OPTION

List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION

Introduction

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

Prototype

int OK_CANCEL_OPTION

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

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:de.mycrobase.jcloudapp.Main.java

private static Map<String, String> showLoginDialog() {
    String message = ""; //"Welcome to JCloudApp!";

    JTextField usernameField = new JTextField();
    JPasswordField passwordField = new JPasswordField();
    JCheckBox remeberCheck = new JCheckBox("Remember login (on disk)");
    remeberCheck.setSelected(true);/*  www . j  ava 2s. c  o m*/
    Object[] content = { message, "Username:", usernameField, "Password:", passwordField, remeberCheck };

    //        int res = JOptionPane.showOptionDialog(
    //            null, content, "JCloudApp - Login",
    //            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, icon,
    //            null, usernameField);
    int res = JOptionPane.showConfirmDialog(null, content, "JCloudApp - Login", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, IconLarge);

    if (res == JOptionPane.OK_OPTION) {
        HashMap<String, String> m = new HashMap<String, String>();
        m.put("username", usernameField.getText());
        m.put("password", new String(passwordField.getPassword()));
        m.put("remember", Boolean.toString(remeberCheck.isSelected()));
        return m;
    } else {
        return null;
    }
}

From source file:gui.DownloadPanel.java

public void actionReDownload() {
    int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to redownload the file?",
            "Confirm Redownload", JOptionPane.OK_CANCEL_OPTION);
    if (action == JOptionPane.OK_OPTION) {
        Download newDownload = selectedDownload;
        try {//from   ww w.  j  av  a  2s  .  co m
            FileUtils.forceDelete(new File(selectedDownload.getDownloadRangePath() + File.separator
                    + selectedDownload.getDownloadName())); // todo must again
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (newDownload.getStatus() == DownloadStatus.COMPLETE) {
            newDownload.resetData();
            newDownload.resume();
            tableSelectionChanged();
        }
    }
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

private void showPropertyEditor(int tabIndex) {
    XYDataset dataset = getChart().getXYPlot().getDataset();
    if (selectedSeriesIndex >= 0 && selectedSeriesIndex < dataset.getSeriesCount()) {
        Plot1DChartEditor.setSuggestedSeriesKey((String) dataset.getSeriesKey(selectedSeriesIndex));
    }/*from  w  w w  .  j  a  v  a2s.  com*/
    Plot1DChartEditor editor = new Plot1DChartEditor(getChart(), this);
    editor.getTabs().setSelectedIndex(tabIndex);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(getChart());
    }
}

From source file:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java

private void filterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterButtonActionPerformed
    int r = JOptionPane.showConfirmDialog(chartPanel, filterPanel, "Select evaluation sample",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (r == JOptionPane.OK_OPTION) {
        updateChart();/*from   w  ww.ja  v a2 s.  com*/
    }
}

From source file:SuitaDetails.java

private void showLib() {
    JScrollPane jScrollPane1 = new JScrollPane();
    JList jList1 = new JList();
    JPanel libraries = new JPanel();
    jScrollPane1.setViewportView(jList1);
    GroupLayout layout = new GroupLayout(libraries);
    libraries.setLayout(layout);/*from  www.jav  a  2  s. c  o  m*/
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1,
            GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE));

    try {
        Object[] s = (Object[]) RunnerRepository.getRPCClient().execute("getLibrariesList",
                new Object[] { RunnerRepository.user });
        String[] libs = new String[s.length];
        for (int i = 0; i < s.length; i++) {
            libs[i] = s[i].toString();
        }
        ArrayList<Integer> ind = new ArrayList<Integer>();
        jList1.setModel(new DefaultComboBoxModel(libs));
        for (String st : globallib) {
            for (int i = 0; i < libs.length; i++) {
                if (libs[i].equals(st)) {
                    ind.add(new Integer(i));
                }
            }
        }
        int[] indices = new int[ind.size()];
        for (int i = 0; i < ind.size(); i++) {
            indices[i] = ind.get(i);
        }
        jList1.setSelectedIndices(indices);

    } catch (Exception e) {
        System.out.println("There was an error on calling getLibrariesList on CE");
        e.printStackTrace();
    }
    int resp = (Integer) CustomDialog.showDialog(libraries, JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION, RunnerRepository.window, "Libraries", null);
    if (resp == JOptionPane.OK_OPTION) {
        Object[] val = jList1.getSelectedValues();
        globallib = new String[val.length];
        for (int s = 0; s < val.length; s++) {
            globallib[s] = val[s].toString();
        }
    }

}

From source file:com.mgmtp.perfload.loadprofiles.ui.dialog.SettingsDialog.java

private void deleteConfigFile() {
    if (JOptionPane.showConfirmDialog(null, "Delete settings?", "Confirmation",
            JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
        int index = cboConfigurationFile.getSelectedIndex();
        String fileName = (String) cboConfigurationFile.getSelectedItem();
        configFiles.remove(fileName);//from  w  ww .j  a  va2 s. c  o m

        index--;
        if (index < 0 && !configFiles.isEmpty()) {
            index = 0;
        }
        cboConfigurationFile.setSelectedIndex(index);

        if (configFiles.isEmpty()) {
            operations.clear();
            targets.clear();
            clients.clear();
            dirty = false;
        }
        controller.deleteSettingsFile(fileName);
    }
}

From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java

public static boolean createVOMSLOCATIONDialog() {
    boolean isSuccessful = false;
    VOMSLocationPanel vomsPanel = new VOMSLocationPanel();

    int result = JOptionPane.showConfirmDialog(null, vomsPanel, "VOMS Location", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, new ResourceIcon(vomsPanel.getClass(), ConfigHelper.ICON));
    if (result == JOptionPane.OK_OPTION) {
        if (vomsPanel.getVOMSLocation() != null && !vomsPanel.getVOMSLocation().equals("")) {
            vomslocation = vomsPanel.getVOMSLocation();
            refreshVOMSConfig();/*ww w  .  j  av a2s.  com*/
            PreferencesStore.put(SshTerminalPanel.PREF_VOMS_LOCATION, vomslocation);
        }
    }

    return isSuccessful;
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

private void filterSampleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterSampleButtonActionPerformed
    int r = JOptionPane.showConfirmDialog(chartPanel, filterPanel, "Select evaluation sample",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (r == JOptionPane.OK_OPTION) {
        updateChart();// w  ww  . ja  v a2 s . c o  m
    }
}

From source file:fi.hoski.remote.ui.Admin.java

private JMenuItem menuItemRemoveEntity() {
    final String title = TextUtil.getText("REMOVE ENTITY");
    JMenuItem removeEntityItem = new JMenuItem(title);
    ActionListener removeEntityAction = new ActionListener() {

        @Override/*from www . j a va2 s . c om*/
        public void actionPerformed(ActionEvent e) {
            Object kind = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION, null,
                    serverProperties.getTables(), null);
            if (kind != null) {
                String confirm = TextUtil.getText("CONFIRM REMOVE") + " " + kind;
                if (JOptionPane.showConfirmDialog(frame, confirm, "",
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                    List<String> kindList = new ArrayList<String>();
                    kindList.add(kind.toString());
                    int count = dss.remove(kindList);
                    JOptionPane.showMessageDialog(frame, TextUtil.getText("REMOVED") + " " + count);
                }
            }
        }
    };
    removeEntityAction = createActionListener(frame, removeEntityAction);
    removeEntityItem.addActionListener(removeEntityAction);
    return removeEntityItem;
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public boolean canCloseDatastore() {
    if (loaded == null) {
        return true;
    }/*from   ww  w.  j a  va2s  . c  om*/

    // if (loaded.isModified()) {
    if (datastoreCloseNeedsUseConfirmation) {
        if (JOptionPane.showConfirmDialog(this, "Any unsaved work will be lost. Do you want to exit?",
                "Confirm exit", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) {
            return false;
        }
    }
    // }

    return true;
}