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)
        throws HeadlessException 

Source Link

Document

Brings up a dialog where the number of choices is determined by the optionType parameter.

Usage

From source file:edu.mit.fss.examples.member.gui.CommSubsystemPanel.java

/**
 * Exports this panel's connectivity dataset.
 *//*from   w  w  w  . ja v a 2s. com*/
private void exportDataset() {
    if (JFileChooser.APPROVE_OPTION == fileChooser.showSaveDialog(this)) {
        File f = fileChooser.getSelectedFile();

        if (!f.exists() || JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this,
                "Overwrite existing file " + f.getName() + "?", "File Exists", JOptionPane.YES_NO_OPTION)) {
            logger.info("Exporting dataset to file " + f.getPath() + ".");
            try {
                BufferedWriter bw = Files.newBufferedWriter(Paths.get(f.getPath()), Charset.defaultCharset());

                StringBuilder b = new StringBuilder();

                // synchronize on map for thread safety
                synchronized (connectSeriesMap) {
                    for (Transmitter tx : connectSeriesMap.keySet()) {
                        TimeSeries s = connectSeriesMap.get(tx);
                        b.append(tx.getName()).append(" Connectivity\n").append("Time, Value\n");
                        for (int j = 0; j < s.getItemCount(); j++) {
                            b.append(s.getTimePeriod(j).getStart().getTime()).append(", ").append(s.getValue(j))
                                    .append("\n");
                        }
                    }
                }

                bw.write(b.toString());
                bw.close();
            } catch (IOException e) {
                logger.error(e);
            }
        }
    }
}

From source file:net.sf.jabref.gui.openoffice.StyleSelectDialog.java

private void setupPopupMenu() {
    popup.add(edit);/*ww  w .j  a  v  a2s . c o m*/
    popup.add(show);
    popup.add(remove);
    popup.add(reload);

    // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor:
    edit.addActionListener(actionEvent -> getSelectedStyle().ifPresent(style -> {
        Optional<ExternalFileType> type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("jstyle");
        String link = style.getPath();
        try {
            if (type.isPresent()) {
                JabRefDesktop.openExternalFileAnyFormat(new BibDatabaseContext(), link, type);
            } else {
                JabRefDesktop.openExternalFileUnknown(frame, new BibEntry(), new BibDatabaseContext(), link,
                        new UnknownExternalFileType("jstyle"));
            }
        } catch (IOException e) {
            LOGGER.warn("Problem open style file editor", e);
        }
    }));

    // Add action listener to "Show" menu item, which is supposed to open the style file in a dialog:
    show.addActionListener(actionEvent -> getSelectedStyle().ifPresent(this::displayStyle));

    // Create action listener for removing a style, also used for the remove button
    removeAction = actionEvent -> getSelectedStyle().ifPresent(style -> {
        if (!style.isFromResource() && (JOptionPane.showConfirmDialog(diag,
                Localization.lang("Are you sure you want to remove the style?"),
                Localization.lang("Remove style"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
            if (!loader.removeStyle(style)) {
                LOGGER.info("Problem removing style");
            }
            updateStyles();
        }
    });
    // Add it to the remove menu item
    remove.addActionListener(removeAction);

    // Add action listener to the "Reload" menu item, which is supposed to reload an external style file
    reload.addActionListener(actionEvent -> getSelectedStyle().ifPresent(style -> {
        try {
            style.ensureUpToDate();
        } catch (IOException e) {
            LOGGER.warn("Problem with style file '" + style.getPath() + "'", e);
        }
    }));

}

From source file:com.freedomotic.jfrontend.PluginConfigure.java

private void uninstallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uninstallButtonActionPerformed
    Plugin item = (Plugin) cmbPlugin.getSelectedItem();

    File boundleRootFolder = item.getFile().getParentFile();
    String uninstallCandidates = clients.getClients().stream().filter(client -> client instanceof Plugin)
            .map(plugin -> (Plugin) plugin)
            .filter(plugin -> plugin.getFile().getParentFile().equals(boundleRootFolder))
            .map(plugin -> "'" + plugin.getName() + "'").collect(Collectors.joining(" "));

    String localizedMessage = api.getI18n().msg("confirm_plugin_delete", new Object[] { uninstallCandidates });

    int result = JOptionPane.showConfirmDialog(null, new JLabel(localizedMessage),
            api.getI18n().msg("confirm_deletion_title"), JOptionPane.OK_CANCEL_OPTION);

    if (result == JOptionPane.OK_OPTION) {
        pluginsManager.uninstallBundle(item);
        dispose();// w w  w .  ja  v  a 2  s.c om
    }
}

From source file:kevin.gvmsgarch.App.java

private static String getPassword() {
    String retval = null;//w w w  . j  a v a2s  . c  om
    JPasswordField pwd = new JPasswordField(20);
    int optionSelected = JOptionPane.showConfirmDialog(null, pwd, "Enter Password",
            JOptionPane.OK_CANCEL_OPTION);
    if (optionSelected == JOptionPane.OK_OPTION) {
        retval = new String(pwd.getPassword());
    }
    return retval;
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java

/**
 * /*  w  w  w  .  j a v a  2 s.  c o  m*/
 */
protected void shutdown() {
    if (schemaLocPanel.hasChanged()) {
        int rv = JOptionPane.showConfirmDialog(this, getResourceString("SchemaLocalizerFrame.SV_CHNGES"), //$NON-NLS-1$
                getResourceString("SchemaLocalizerFrame.CHGS_SAVED"), JOptionPane.YES_NO_OPTION); // I18N  //$NON-NLS-1$
        if (rv == JOptionPane.YES_OPTION) {
            write();
        }
    }

    //helper.dumpAsNew(panel.getTables());
    setVisible(false);
    System.exit(0);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java

/**
 * Handles the pressing of the {@link #btnFilter} button.
 * <p>//from w  w  w. j a va  2 s .com
 * After asking the user for confirmation, this method adds or removes filter to the complex
 * parameter displayed.
 * </p>
 */
private void performFilter() {
    if (originalParam == visualizer.getComplexParam()) {
        // Create filter
        try {
            final Class<?> paramClass = originalParam.getClass();
            final Class<?> filterClass = Plugin.getFilterDialogClass(paramClass);
            final Constructor<?> constr = filterClass.getConstructors()[0];
            Object[] cParams = new Object[] { ownerDialog, Messages.DT_FILTERDATA, originalParam,
                    visualizer.getSettings() };
            ComplexParamFilterDialog d = (ComplexParamFilterDialog) constr.newInstance(cParams);
            ComplexParamFilter filter = d.showDialog();
            if (filter != null) {
                btnFilter.setText(Messages.DI_REMOVEFILTER);
                btnFilter.setToolTipText(Messages.TT_REMOVEFILTER);
                visualizer.setComplexParam(filter.filter(originalParam));
                chart = visualizer.createControl();
                JFreeChartConn.setChart(chartPanel, chart);
            }
        } catch (InnerException ex) {
            // NetworkAnalyzer internal error
            logger.error(Messages.SM_LOGERROR, ex);
        } catch (SecurityException ex) {
            Utils.showErrorBox(this, Messages.DT_SECERROR, Messages.SM_SECERROR2);
        } catch (Exception ex) {
            // ClassCastException, ClassNotFoundException, IllegalAccessException
            // IllegalArgumentException, InstantiationException, InvocationTargetException
            // NetworkAnalyzer internal error
            logger.error(Messages.SM_LOGERROR, ex);
        }

    } else {
        // Remove filter
        int res = JOptionPane.showConfirmDialog(this, Messages.SM_REMOVEFILTER, Messages.DT_REMOVEFILTER,
                JOptionPane.YES_NO_OPTION);
        if (res == JOptionPane.YES_OPTION) {
            btnFilter.setText(Messages.DI_FILTERDATA);
            btnFilter.setToolTipText(Messages.TT_FILTERDATA);
            visualizer.setComplexParam(originalParam);
            chart = visualizer.createControl();
            JFreeChartConn.setChart(chartPanel, chart);
        }
    }
}

From source file:edu.ku.brc.af.ui.db.JAutoCompTextField.java

/**
 * It may or may not ask if it can add, and then it adds the new item.
 * @param strArg the string that is to be added
 * @return whether it was added//w w w  . j  a  va 2  s  . c o  m
 */
protected boolean askToAdd(String strArg) {

    if (ignoreFocus) {
        return false;
    }

    if (hasChanged && isNotEmpty(strArg)) {
        ignoreFocus = true;
        String msg = UIRegistry.getLocalizedMessage("JAutoCompTextField.REMEM_VAL", strArg); //$NON-NLS-1$
        if (!askBeforeSave || JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, msg,
                UIRegistry.getResourceString("JAutoCompTextField.REMEM_VAL_TITLE"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                JOptionPane.YES_NO_OPTION)) {
            if (dbAdapter != null) {
                dbAdapter.addItem(strArg, null);
            }
            hasChanged = false;
            ignoreFocus = false;
            return true;
        }
        ignoreFocus = false;
    }
    return false;
}

From source file:com.clough.android.adbv.view.UpdateTableDialog.java

private void showTableChangeOptionMenu(int x, int y, final int rowIndex) {
    JPopupMenu tableChangeOptionPopupMenu = new JPopupMenu();
    JMenuItem newRowMenuItem = new JMenuItem("Add row");
    newRowMenuItem.addActionListener(new ActionListener() {

        @Override/* w w  w  .  ja va 2  s .  com*/
        public void actionPerformed(ActionEvent e) {
            new AddUpdateRowDialog(defaultTableModel, rowController, columnNames, null, -1).setVisible(true);
        }
    });
    JMenuItem updateRowMenuItem = new JMenuItem("Update row");
    updateRowMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Object[] row = new Object[columnNames.length];
            for (int columnIndex = 0; columnIndex < row.length; columnIndex++) {
                row[columnIndex] = defaultTableModel.getValueAt(rowIndex, columnIndex);
            }
            new AddUpdateRowDialog(defaultTableModel, rowController, columnNames, row, rowIndex)
                    .setVisible(true);
            tableColumnAdjuster.adjustColumns();
        }
    });
    JMenuItem removeRowMenuItem = new JMenuItem("Remove row");
    removeRowMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(null, "Are you sure you want to remove this row?", "Remove row",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                defaultTableModel.removeRow(rowIndex);
                rowController.removeRow(rowIndex);
                tableColumnAdjuster.adjustColumns();
            }
        }
    });
    tableChangeOptionPopupMenu.add(newRowMenuItem);
    tableChangeOptionPopupMenu.add(updateRowMenuItem);
    tableChangeOptionPopupMenu.add(removeRowMenuItem);
    tableChangeOptionPopupMenu.show(this, x, y);
}

From source file:view.App.java

private void initGUI() {
    try {//from ww  w .  ja  v  a2s  .  c  o  m
        {
            jPanel1 = new JPanel();
            BorderLayout jPanel1Layout = new BorderLayout();
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, BorderLayout.CENTER);
            jPanel1.setPreferredSize(new java.awt.Dimension(901, 398));
            {
                jPanel2 = new JPanel();
                BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS);
                jPanel2.setLayout(jPanel2Layout);
                jPanel1.add(jPanel2, BorderLayout.WEST);
                jPanel2.setPreferredSize(new java.awt.Dimension(292, 446));
                {
                    jPanel5 = new JPanel();
                    jPanel2.add(jPanel5);
                    jPanel5.setPreferredSize(new java.awt.Dimension(292, 109));
                    {
                        {
                            jTextArea1 = new JTextArea();
                            jTextArea1.setWrapStyleWord(true);
                            jTextArea1.setLineWrap(true);
                            DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret();
                            caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

                            jTextArea1.addFocusListener(new FocusAdapter() {
                                public void focusGained(FocusEvent evt) {

                                    if (jTable1.getModel().getRowCount() == 0 && !jButton1.isEnabled()) {
                                        jButton1.setEnabled(true);
                                        jTextArea1.setText("");
                                    }

                                }
                            });
                            JScrollPane sp = new JScrollPane();
                            sp.setPreferredSize(new java.awt.Dimension(281, 97));
                            sp.setViewportView(jTextArea1);

                            jPanel5.add(sp, BorderLayout.CENTER);
                        }
                    }

                }
                {
                    jPanel4 = new JPanel();
                    jPanel2.add(jPanel4);
                    FlowLayout jPanel4Layout = new FlowLayout();
                    jPanel4Layout.setAlignment(FlowLayout.RIGHT);
                    jPanel4.setPreferredSize(new java.awt.Dimension(292, 45));
                    jPanel4.setSize(102, 51);
                    jPanel4.setLayout(jPanel4Layout);
                    {
                        jButton1 = new JButton();
                        jPanel4.add(jButton1);
                        jButton1.setText("Get Quotes");
                        jButton1.setSize(100, 50);
                        jButton1.setPreferredSize(new java.awt.Dimension(100, 26));
                        jButton1.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                //   
                                String tickerStr = jTextArea1.getText();
                                if (tickerStr.equals("") || tickerStr.equals(null)
                                        || tickerStr.equals(" ")) {
                                    jTextArea1.setText(" ");
                                    return;
                                }
                                StringTokenizer tokenizer = new StringTokenizer(tickerStr, " ");
                                String[] tickers = new String[tokenizer.countTokens()];
                                int i = 0;
                                while (tokenizer.hasMoreTokens()) {
                                    tickers[i] = tokenizer.nextToken();
                                    i++;
                                }
                                try {
                                    Controller.getQuotes(tickers);
                                } catch (CloneNotSupportedException e) {
                                    JOptionPane.showMessageDialog(jPanel1, "   ");
                                }
                                jButton1.setEnabled(false);
                            }
                        });
                    }
                }
                {
                    jPanel6 = new JPanel();
                    BorderLayout jPanel6Layout = new BorderLayout();
                    jPanel6.setLayout(jPanel6Layout);
                    jPanel2.add(jPanel6);
                    {
                        jScrollPane1 = new JScrollPane();
                        jPanel6.add(jScrollPane1, BorderLayout.CENTER);
                        jScrollPane1.setPreferredSize(new java.awt.Dimension(292, 341));
                        {
                            TableModel jTable1Model = new DefaultTableModel(null,
                                    new String[] { "", "MA Value", "", "MA Value" });
                            jTable1 = new JTable();

                            jScrollPane1.setViewportView(jTable1);
                            jTable1.setModel(jTable1Model);
                            jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

                        }
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jPanel1.add(jPanel3, BorderLayout.CENTER);
                {
                    //                  chart = ChartFactory.createLineChart(" ", "dates", "correlation ratio", null, 
                    //                        PlotOrientation.VERTICAL, true, true, false);
                    //                  ChartPanel chartPanel = new ChartPanel(chart);
                    //                  chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) );
                    //                  jPanel3.add(chartPanel);
                }
                {

                }
            }
        }
        this.setSize(966, 531);
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                jMenu3 = new JMenu();
                jMenuBar1.add(jMenu3);
                jMenu3.setText("File");
                {
                    //                  newFileMenuItem = new JMenuItem();
                    //                  jMenu3.add(newFileMenuItem);
                    //                  newFileMenuItem.setText("New");
                    //                  newFileMenuItem.addActionListener(new ActionListener() {
                    //                     public void actionPerformed(ActionEvent evt) {
                    ////                        jTextArea1.setText("");
                    ////                        DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
                    ////                        model.setRowCount(0);
                    ////                        Controller.clearPortfolio();
                    //                     }
                    //                  });
                }
                {
                    jSeparator2 = new JSeparator();
                    jMenu3.add(jSeparator2);
                }
                {
                    exitMenuItem = new JMenuItem();
                    jMenu3.add(exitMenuItem);
                    exitMenuItem.setText("Exit");
                    exitMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            int action = JOptionPane.showConfirmDialog(jPanel1,
                                    "     ?", "Confirm Exit",
                                    JOptionPane.OK_CANCEL_OPTION);

                            if (action == JOptionPane.OK_OPTION)
                                System.exit(0);

                        }
                    });
                }
            }
            {
                jMenu4 = new JMenu();
                jMenuBar1.add(jMenu4);
                jMenu4.setText("Edit");
                {
                    cutMenuItem = new JMenuItem();
                    jMenu4.add(cutMenuItem);
                    cutMenuItem.setText("Cut");
                    cutMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            String txt = jTextArea1.getText();
                            StringSelection selection = new StringSelection(txt);
                            Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
                            clp.setContents(selection, null);
                            jTextArea1.setText("");

                        }
                    });
                }
                {
                    copyMenuItem = new JMenuItem();
                    jMenu4.add(copyMenuItem);
                    copyMenuItem.setText("Copy");
                    copyMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                            String txt = jTextArea1.getText();
                            StringSelection selection = new StringSelection(txt);
                            Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
                            clp.setContents(selection, null);

                        }
                    });
                }
                {
                    pasteMenuItem = new JMenuItem();
                    jMenu4.add(pasteMenuItem);
                    pasteMenuItem.setText("Paste");
                    pasteMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
                            try {
                                String data = (String) clp.getData(DataFlavor.stringFlavor);
                                jTextArea1.setText(data);
                            } catch (UnsupportedFlavorException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            } catch (IOException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }
                        }
                    });
                }
            }
            {
                jMenu5 = new JMenu();
                jMenuBar1.add(jMenu5);
                jMenu5.setText("Help");
                {
                    helpMenuItem = new JMenuItem();
                    jMenu5.add(helpMenuItem);
                    helpMenuItem.setText("About");
                    helpMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                            JOptionPane.showMessageDialog(jPanel1,
                                    "    .    r.zhumagulov@gmail.com",
                                    "About", JOptionPane.PLAIN_MESSAGE);

                        }
                    });
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.specify.conversion.CustomDBConverterPanel.java

/**
 * Creates the UI for the login and hooks up any listeners.
 * @param isDlg  whether the parent is a dialog (false mean JFrame)
 *///from  w w w .  j a v a 2 s.  co m
protected void createUI(final boolean isDlg) {
    PropertiesPickListAdapter dbPickList = new PropertiesPickListAdapter("convert.databasesSource");
    PropertiesPickListAdapter svPickList = new PropertiesPickListAdapter("convert.serversSource");

    PropertiesPickListAdapter dbDestPickList = new PropertiesPickListAdapter("convert.databasesDest");
    PropertiesPickListAdapter svDestPickList = new PropertiesPickListAdapter("convert.serversDest");

    usernameSource = createTextField(20);
    passwordSource = createPasswordField(20);

    usernameDest = createTextField(20);
    passwordDest = createPasswordField(20);

    databasesSource = new ValComboBox(dbPickList);
    serversSource = new ValComboBox(svPickList);

    databasesDest = new ValComboBox(dbDestPickList);
    serversDest = new ValComboBox(svDestPickList);

    setControlSize(passwordSource);
    setControlSize(passwordDest);
    setControlSize(databasesSource);
    setControlSize(serversSource);
    setControlSize(databasesDest);
    setControlSize(serversDest);

    dbPickList.setComboBox(databasesSource);
    svPickList.setComboBox(serversSource);

    dbDestPickList.setComboBox(databasesDest);
    svDestPickList.setComboBox(serversDest);

    // autoLoginSourceCBX = createCheckBox(getResourceString("autologin"));
    rememberUsernameSourceCBX = createCheckBox(getResourceString("rememberuser"));
    rememberPasswordSourceCBX = createCheckBox(getResourceString("rememberpassword"));

    autoLoginDestCBX = createCheckBox(getResourceString("autologin"));
    rememberUsernameDestCBX = createCheckBox(getResourceString("rememberuser"));
    rememberPasswordDestCBX = createCheckBox(getResourceString("rememberpassword"));

    statusBar = new JStatusBar();
    statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16));

    cancelBtn = createButton(getResourceString("CANCEL"));
    loginBtn = createButton(getResourceString("Login"));
    helpBtn = createButton(getResourceString("HELP"));

    forwardImgIcon = IconManager.getIcon("Forward");
    downImgIcon = IconManager.getIcon("Down");
    //moreBtn = createCheckBox("More", forwardImgIcon); // XXX I18N

    // Extra
    dbDrivers = DatabaseDriverInfo.getDriversList();
    dbDriverCBX = createComboBox(dbDrivers);
    dbDriverCBX2 = createComboBox(dbDrivers);

    if (dbDrivers.size() > 0) {
        String selectedStr = AppPreferences.getLocalPrefs().get("convert.dbdriverSource_selected", "SQLServer");
        int inx = Collections.binarySearch(dbDrivers,
                new DatabaseDriverInfo(selectedStr, null, null, false, null));
        dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1);
        selectedStr = AppPreferences.getLocalPrefs().get("convert.dbdriverDest_selected", "SQLServer");
        inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null));
        dbDriverCBX2.setSelectedIndex(inx > -1 ? inx : -1);

    } else {
        JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"),
                getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION);
        System.exit(1);
    }

    dbDriverCBX.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUIControls();
        }
    });

    dbDriverCBX2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUIControls();
        }
    });
    addFocusListenerForTextComp(usernameSource);
    addFocusListenerForTextComp(passwordSource);

    addKeyListenerFor(usernameSource, !isDlg);
    addKeyListenerFor(passwordSource, !isDlg);

    addKeyListenerFor(databasesSource.getTextField(), !isDlg);
    addKeyListenerFor(serversSource.getTextField(), !isDlg);

    addFocusListenerForTextComp(usernameDest);
    addFocusListenerForTextComp(passwordDest);

    addKeyListenerFor(usernameDest, !isDlg);
    addKeyListenerFor(passwordDest, !isDlg);

    addKeyListenerFor(databasesDest.getTextField(), !isDlg);
    addKeyListenerFor(serversDest.getTextField(), !isDlg);

    if (!isDlg) {
        addKeyListenerFor(loginBtn, true);
    }

    //autoLoginSourceCBX.setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.autologin", false));
    rememberUsernameSourceCBX
            .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberuserSource", false));
    rememberPasswordSourceCBX
            .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberpasswordSource", false));

    autoLoginDestCBX.setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.autologin2", false));
    rememberUsernameDestCBX
            .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberuserDest", false));
    rememberPasswordDestCBX
            .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberpasswordDest", false));

    //        if (autoLoginSourceCBX.isSelected())
    //        {
    //            usernameSource.setText(AppPreferences.getLocalPrefs().get("convert.usernameSource", ""));
    //            passwordSource.setText(Encryption.decrypt(AppPreferences.getLocalPrefs().get(
    //                    "convert.passwordSource", "")));
    //            usernameSource.requestFocus();
    //
    //        } else
    //        {
    if (rememberUsernameSourceCBX.isSelected()) {
        usernameSource.setText(AppPreferences.getLocalPrefs().get("convert.usernameSource", ""));
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                passwordSource.requestFocus();
            }
        });

    }

    if (rememberPasswordSourceCBX.isSelected()) {
        passwordSource
                .setText(Encryption.decrypt(AppPreferences.getLocalPrefs().get("convert.passwordSource", "")));
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                loginBtn.requestFocus();
            }
        });

    }
    //}

    if (autoLoginDestCBX.isSelected()) {
        usernameDest.setText(AppPreferences.getLocalPrefs().get("convert.usernameDest", ""));
        passwordDest
                .setText(Encryption.decrypt(AppPreferences.getLocalPrefs().get("convert.passwordDest", "")));
        usernameDest.requestFocus();

    } else {
        if (rememberUsernameDestCBX.isSelected()) {
            usernameDest.setText(AppPreferences.getLocalPrefs().get("convert.usernameDest", ""));
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    passwordDest.requestFocus();
                }
            });

        }

        if (rememberPasswordDestCBX.isSelected()) {
            passwordDest.setText(
                    Encryption.decrypt(AppPreferences.getLocalPrefs().get("convert.passwordDest", "")));
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    loginBtn.requestFocus();
                }
            });

        }
    }
    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (dbConverterListener != null) {
                dbConverterListener.cancelled();
            }
        }
    });

    loginBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doLogin();
        }
    });

    //HelpManager.registerComponent(helpBtn, "login");
    HelpMgr.registerComponent(helpBtn, "convert");

    //        autoLoginSourceCBX.addChangeListener(new ChangeListener()
    //        {
    //            public void stateChanged(ChangeEvent e)
    //            {
    //                if (autoLoginSourceCBX.isSelected())
    //                {
    //                    rememberUsernameSourceCBX.setSelected(true);
    //                    rememberPasswordSourceCBX.setSelected(true);
    //                }
    //                updateUIControls();
    //            }
    //
    //        });

    //        moreBtn.addActionListener(new ActionListener()
    //        {
    //            public void actionPerformed(ActionEvent e)
    //            {
    //                if (extraPanel.isVisible())
    //                {
    //                    if (dbDriverCBX.getSelectedIndex() != -1)
    //                    {
    //                        extraPanel.setVisible(false);
    //                        moreBtn.setIcon(forwardImgIcon);
    //                    }
    //
    //                } else
    //                {
    //                    extraPanel.setVisible(true);
    //                    moreBtn.setIcon(downImgIcon);
    //                }
    //                if (window != null)
    //                {
    //                    window.pack();
    //                }
    //            }
    //        });

    // Ask the PropertiesPickListAdapter to set the index from the prefs
    dbPickList.setSelectedIndex();
    svPickList.setSelectedIndex();

    dbDestPickList.setSelectedIndex();
    svDestPickList.setSelectedIndex();

    serversSource.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databasesSource.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    // Layout the form
    JPanel p = new JPanel();//FormDebugPanel();
    PanelBuilder formBuilder = new PanelBuilder(
            new FormLayout("p,3dlu,max(220px;p):g,3dlu,p,3dlu,max(220px;p):g",
                    UIHelper.createDuplicateJGoodiesDef("p", "2dlu", 13)),
            p);
    CellConstraints cc = new CellConstraints();
    formBuilder.addSeparator(getResourceString("SOURCE_DB"), cc.xywh(1, 1, 3, 1));

    int y = 3;
    y = addLine("username", usernameSource, formBuilder, cc, y);
    y = addLine("password", passwordSource, formBuilder, cc, y);
    y = addLine("databases", databasesSource, formBuilder, cc, y);
    y = addLine("servers", serversSource, formBuilder, cc, y);
    //        formBuilder.addSeparator(getResourceString("extratitle"), cc.xywh(1, y, 3, 1));
    //        y +=2;
    y = addLine("driver", dbDriverCBX, formBuilder, cc, y);
    y = addLine(null, rememberUsernameSourceCBX, formBuilder, cc, y);
    y = addLine(null, rememberPasswordSourceCBX, formBuilder, cc, y);
    //y = addLine(null, autoLoginSourceCBX, formBuilder, cc, y);

    int x = 5;
    formBuilder.addSeparator(getResourceString("DEST_DB"), cc.xywh(x, 1, 3, 1));
    y = 3;

    y = addLine("username", usernameDest, formBuilder, cc, x, y);
    y = addLine("password", passwordDest, formBuilder, cc, x, y);
    y = addLine("databases", databasesDest, formBuilder, cc, x, y);
    y = addLine("servers", serversDest, formBuilder, cc, x, y);
    //        formBuilder.addSeparator(getResourceString("extratitle"), cc.xywh(1, y, 3, 1));
    //        y +=2;
    y = addLine("driver", dbDriverCBX2, formBuilder, cc, x, y);
    y = addLine(null, rememberUsernameDestCBX, formBuilder, cc, x, y);
    y = addLine(null, rememberPasswordDestCBX, formBuilder, cc, x, y);
    y = addLine(null, autoLoginDestCBX, formBuilder, cc, x, y);

    PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,max(220px;p):g", "p,2dlu,p,2dlu,p"));
    extraPanel = extraPanelBlder.getPanel();
    extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2));

    //formBuilder.add(moreBtn, cc.xy(1, y));
    //y += 2;

    //extraPanelBlder.addSeparator(getResourceString("extratitle"), cc.xywh(1, 1, 3, 1));
    //addLine("driver", dbDriverCBX, extraPanelBlder, cc, 3);
    //extraPanel.setVisible(false);

    //formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(1, y, 3, 1));

    PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p"), this);
    //JLabel icon = createLabel(IconManager.getIcon("SpecifyLargeIcon"));
    //icon.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 2));

    formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 5));

    //outerPanel.add(icon, cc.xy(1, 1));
    outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1));
    outerPanel.add(ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn), cc.xywh(1, 3, 3, 1));
    outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1));

    updateUIControls();
}