Example usage for javax.swing JOptionPane showConfirmDialog

List of usage examples for javax.swing JOptionPane showConfirmDialog

Introduction

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

Prototype

public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType,
        int messageType, Icon icon) throws HeadlessException 

Source Link

Document

Brings up a dialog with a specified icon, where the number of choices is determined by the optionType parameter.

Usage

From source file:Import.pnl_import_vcf.java

private void btn_importActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_importActionPerformed
    // TODO add your handling code here:
    String[] singleColumns = singleColumns();
    String[] selectedFamilies = selectedFamilies();
    CheckBoxList checkList = new CheckBoxList();
    DefaultListModel model = new DefaultListModel();
    for (String a : singleColumns) {
        model.addElement(a);//from  w w  w  .j  av a2s . c  om
    }
    checkList.setModel(model);
    String filePath = filePathField.getText();
    if (rbt_existing_tbl.isSelected()) {
        try {
            String[] selectedTableFamilies = tableFamilies();
            JTable tableMap = new JTable();
            DefaultTableModel tableMapModel = (DefaultTableModel) tableMap.getModel();
            setMapTable(tableMap, tableMapModel, selectedFamilies, selectedTableFamilies);
            int map = JOptionPane.showConfirmDialog(null, tableMap, "Please map to column",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null);
            if (map == 2) {
                return;
            }
            Object[] o = getMapPair(tableMapModel);
            String selectTableName = tbl_hbase_tables.getValueAt(tbl_hbase_tables.getSelectedRow(), 0)
                    .toString();
            String[] mappedFamilies = (String[]) o[1];
            String[] mappedTableFamilies = (String[]) o[0];
            String[] keys = getKey(selectTableName);
            importToTable.importDataJob importData = new importDataJob();
            importData.importData(filePath, selectTableName, mappedTableFamilies, mappedFamilies, keys);
        } catch (Exception ex) {
            Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        try {
            int key = JOptionPane.showConfirmDialog(null, checkList, "Please choose Key",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null);
            if (key == 2) {
                return;
            }
            Object[] selectedKey = checkList.getCheckBoxListSelectedValues();
            File f = new File(filePath);
            String fname = f.getName();
            String tableName = FilenameUtils.removeExtension(fname);
            writeKey(selectedKey, tableName);
            writeType(tableName);
            createColumnsTxt(tableName);
            ArrayList<String> list = new ArrayList<>();
            for (Object o : selectedKey) {
                list.add(o.toString());
            }
            String[] keys = list.toArray(new String[list.size()]);
            importToNewTable.createDataJob importData = new createDataJob();
            importData.importData(filePath, selectedFamilies, keys);
        } catch (Exception ex) {
            Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    filePathField.setText(null);
    DefaultDualListModel dualModel = new DefaultDualListModel();
    list_dual_hbase_column_family.setModel(dualModel);
    pnl_import_vcf.showHBaseTables runabletask = new pnl_import_vcf.showHBaseTables();
    new Thread(runabletask).start();
}

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);//w w  w  . j a  v a 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: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();//from w w w . j  a va  2  s .  co  m
            PreferencesStore.put(SshTerminalPanel.PREF_VOMS_LOCATION, vomslocation);
        }
    }

    return isSuccessful;
}

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

public static boolean createAddVODialog() {
    boolean isSuccessful = false;
    NewVOPanel newVOPanel = new NewVOPanel();

    while (true) {
        int result = JOptionPane.showConfirmDialog(null, newVOPanel, "New VO", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, new ResourceIcon(newVOPanel.getClass(), ConfigHelper.ICON));

        if (result == JOptionPane.OK_OPTION) {

            String msg = "";
            if (newVOPanel.getServerIssuerDN().equals("")) {
                msg = "Field 'Server Certificate Issuer DN' cannot be empty.";
            }/*  w  w  w  .j  av  a  2s . c  om*/
            if (newVOPanel.getServerDN().equals("")) {
                msg = "Field 'Server DN' cannot be empty.\n" + msg;
            }
            if (newVOPanel.getPort() == 0) {
                msg = "Field 'Port' cannot be empty.\n" + msg;
            }
            if (newVOPanel.getServer().equals("")) {
                msg = "Field 'Server' cannot be empty.\n" + msg;
            }
            if (newVOPanel.getVOName().equals("")) {
                msg = "Field 'VO name' cannot be empty.\n" + msg;
            }

            if (!msg.equals("")) {
                JOptionPane.showMessageDialog(null, msg, "Error: Add new VO", JOptionPane.ERROR_MESSAGE);
            } else {
                TreeMap vo = new TreeMap();
                vo.put("localvoname", newVOPanel.getVOName());
                vo.put("servervoname", newVOPanel.getVOName());
                vo.put("server", newVOPanel.getServer());
                vo.put("port", newVOPanel.getPort());
                vo.put("serverdn", newVOPanel.getServerDN());
                vo.put("serverissuerdn", newVOPanel.getServerIssuerDN());
                try {
                    isSuccessful = addNewVO(vo);
                    break;
                } catch (IOException e) {
                    JOptionPane.showMessageDialog(null, e.getMessage(), "Error: Add new VO",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        } else {
            break;
        }
    }

    return isSuccessful;
}