Example usage for javax.swing JOptionPane CLOSED_OPTION

List of usage examples for javax.swing JOptionPane CLOSED_OPTION

Introduction

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

Prototype

int CLOSED_OPTION

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

Click Source Link

Document

Return value from class method if user closes window without selecting anything, more than likely this should be treated as either a CANCEL_OPTION or NO_OPTION.

Usage

From source file:MessagePopup.java

public static int getSelection(JOptionPane optionPane) {
    // Default return value, signals nothing selected
    int returnValue = JOptionPane.CLOSED_OPTION;

    // Get selected Value
    Object selectedValue = optionPane.getValue();
    System.out.println(selectedValue);

    // If none, then nothing selected
    if (selectedValue != null) {
        Object options[] = optionPane.getOptions();
        if (options == null) {
            // default buttons, no array specified
            if (selectedValue instanceof Integer) {
                returnValue = ((Integer) selectedValue).intValue();
            }/* w  ww  . j  a  v a2 s .co  m*/
        } else {
            // Array of option buttons specified
            for (int i = 0, n = options.length; i < n; i++) {
                if (options[i].equals(selectedValue)) {
                    returnValue = i;
                    break; // out of for loop
                }
            }
        }
    }
    return returnValue;
}

From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java

private void showErrorWindow(String title, String body) {
    try {//w w w  . jav a 2 s .  c om
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            System.setProperty("apple.awt.UIElement", "false");

        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        JTextArea textArea = new JTextArea(body);
        JScrollPane scrollPane = new JScrollPane(textArea);
        textArea.setLineWrap(true);
        textArea.setFont(Font.getFont(Font.MONOSPACED));
        textArea.setEditable(false);
        textArea.setWrapStyleWord(true);
        scrollPane.setPreferredSize(new Dimension(500, 500));

        JTextPane titleLabel = new JTextPane();
        titleLabel.setContentType("text/html"); // let the text pane know this is what you want
        titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off
        titleLabel.setEditable(false);
        titleLabel.setBackground(null);
        titleLabel.setBorder(null);

        panel.add(titleLabel);
        panel.add(scrollPane);

        final JFrame frame = new JFrame();
        frame.setAlwaysOnTop(true);
        moveCenter(frame);
        frame.setVisible(true);

        JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.",
                JOptionPane.CLOSED_OPTION);
        System.exit(1);
    } catch (Exception e) {
        log.error("Problem showing error window", e);
    }
}

From source file:com.mirth.connect.client.ui.SettingsPanelMap.java

public void doExportMap() {
    if (isSaveEnabled()) {
        int option = JOptionPane.showConfirmDialog(this, "Would you like to save the settings first?");

        if (option == JOptionPane.YES_OPTION) {
            if (!doSave()) {
                return;
            }/*  w w  w  . ja  v  a 2s .c o m*/
        } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) {
            return;
        }
    }

    final String workingId = getFrame().startWorking("Exporting " + getTabName() + " settings...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        private Map<String, ConfigurationProperty> configurationMap;

        public Void doInBackground() {
            try {
                File file = getFrame().createFileForExport(null, "PROPERTIES");
                if (file != null) {
                    PropertiesConfiguration properties = new PropertiesConfiguration();
                    properties.setDelimiterParsingDisabled(true);
                    properties.setListDelimiter((char) 0);
                    properties.clear();
                    PropertiesConfigurationLayout layout = properties.getLayout();

                    configurationMap = getFrame().mirthClient.getConfigurationMap();
                    Map<String, ConfigurationProperty> sortedMap = new TreeMap<String, ConfigurationProperty>(
                            String.CASE_INSENSITIVE_ORDER);
                    sortedMap.putAll(configurationMap);

                    for (Entry<String, ConfigurationProperty> entry : sortedMap.entrySet()) {
                        String key = entry.getKey();
                        String value = entry.getValue().getValue();
                        String comment = entry.getValue().getComment();

                        if (StringUtils.isNotBlank(key)) {
                            properties.setProperty(key, value);
                            layout.setComment(key, StringUtils.isBlank(comment) ? null : comment);
                        }
                    }

                    properties.save(file);
                }
            } catch (Exception e) {
                getFrame().alertThrowable(getFrame(), e);
            }

            return null;
        }

        @Override
        public void done() {
            getFrame().stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:com.sshtools.tunnel.PortForwardingPane.java

protected void addPortForward() {
    PortForwardEditorPane editor = new PortForwardEditorPane();
    int option = JOptionPane.showConfirmDialog(this, editor, "Add New Tunnel", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (option != JOptionPane.CANCEL_OPTION && option != JOptionPane.CLOSED_OPTION) {
        try {//from  www  .j  a v  a2  s. c o  m
            ForwardingClient forwardingClient = client; //.getForwardingClient();
            String id = editor.getForwardName();
            if (id.equals("x11")) {
                throw new Exception("The id of x11 is reserved.");
            }
            int i = model.getRowCount();
            if (editor.isLocal()) {
                ForwardingConfiguration f = forwardingClient.addLocalForwarding(id, editor.getBindAddress(),
                        editor.getLocalPort(), editor.getHost(), editor.getRemotePort());
                forwardingClient.startLocalForwarding(id);
                active.addConfiguration(f);
            } else {
                ForwardingConfiguration f = forwardingClient.addRemoteForwarding(id, editor.getBindAddress(),
                        editor.getLocalPort(), editor.getHost(), editor.getRemotePort());
                forwardingClient.startRemoteForwarding(id);
                active.addConfiguration(f);
            }

            if (i < model.getRowCount()) {
                table.getSelectionModel().addSelectionInterval(i, i);
            }
        } catch (Exception e) {
            sessionPanel.setAvailableActions();
            JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } finally {
            model.refresh();
            sessionPanel.setAvailableActions();
        }
    }
}

From source file:com.t3.macro.api.functions.input.InputFunctions.java

/**
 * <pre>/*www.  ja  v a  2s  .  com*/
 * <span style="font-family:sans-serif;">The input() function prompts the user to input several variable values at once.
 * 
 * Each of the string parameters has the following format:
 *     "varname|value|prompt|inputType|options"
 * 
 * Only the first section is required.
 *     varname   - the variable name to be assigned
 *     value     - sets the initial contents of the input field
 *     prompt    - UI text shown for the variable
 *     inputType - specifies the type of input field
 *     options   - a string of the form "opt1=val1; opt2=val2; ..."
 * 
 * The inputType field can be any of the following (defaults to TEXT):
 *     TEXT  - A text field.
 *             "value" sets the initial contents.
 *             The return value is the string in the text field.
 *             Option: WIDTH=nnn sets the width of the text field (default 16).
 *     LIST  - An uneditable combo box.
 *             "value" populates the list, and has the form "item1,item2,item3..." (trailing empty strings are dropped)
 *             The return value is the numeric index of the selected item.
 *             Option: SELECT=nnn sets the initial selection (default 0).
 *             Option: VALUE=STRING returns the string contents of the selected item (default NUMBER).
 *             Option: TEXT=FALSE suppresses the text of the list item (default TRUE).
 *             Option: ICON=TRUE causes icon asset URLs to be extracted from the "value" and displayed (default FALSE).
 *             Option: ICONSIZE=nnn sets the size of the icons (default 50).
 *     CHECK - A checkbox.
 *             "value" sets the initial state of the box (anything but "" or "0" checks the box)
 *             The return value is 0 or 1.
 *             No options.
 *     RADIO - A group of radio buttons.
 *             "value" is a list "name1, name2, name3, ..." which sets the labels of the buttons.
 *             The return value is the index of the selected item.
 *             Option: SELECT=nnn sets the initial selection (default 0).
 *             Option: ORIENT=H causes the radio buttons to be laid out on one line (default V).
 *             Option: VALUE=STRING causes the return value to be the string of the selected item (default NUMBER).
 *     LABEL - A label.
 *             The "varname" is ignored and no value is assigned to it.
 *             Option: TEXT=FALSE, ICON=TRUE, ICONSIZE=nnn, as in the LIST type.
 *     PROPS - A sub-panel with multiple text boxes.
 *             "value" contains a StrProp of the form "key1=val1; key2=val2; ..."
 *             One text box is created for each key, populated with the matching value.
 *             Option: SETVARS=SUFFIXED causes variable assignment to each key name, with appended "_" (default NONE).
 *             Option: SETVARS=UNSUFFIXED causes variable assignment to each key name.
 *     TAB   - A tabbed dialog tab is created.  Subsequent variables are contained in the tab.
 *             Option: SELECT=TRUE causes this tab to be shown at start (default SELECT=FALSE).
 * 
 *  All inputTypes except TAB accept the option SPAN=TRUE, which causes the prompt to be hidden and the input
 *  control to span both columns of the dialog layout (default FALSE).
 * </span>
 * </pre>
 * @param parameters a list of strings containing information as described above
 * @return a HashMap with the returned values or null if the user clicked on cancel
 * @author knizia.fan
 * @throws MacroException 
 */
public static Map<String, String> input(TokenView token, String... parameters) throws MacroException {
    // Extract the list of specifier strings from the parameters
    // "name | value | prompt | inputType | options"
    List<String> varStrings = new ArrayList<String>();
    for (Object param : parameters) {
        String paramStr = (String) param;
        if (StringUtils.isEmpty(paramStr)) {
            continue;
        }
        // Multiple vars can be packed into a string, separated by "##"
        for (String varString : StringUtils.splitByWholeSeparator(paramStr, "##")) {
            if (StringUtils.isEmpty(paramStr)) {
                continue;
            }
            varStrings.add(varString);
        }
    }

    // Create VarSpec objects from each variable's specifier string
    List<VarSpec> varSpecs = new ArrayList<VarSpec>();
    for (String specifier : varStrings) {
        VarSpec vs;
        try {
            vs = new VarSpec(specifier);
        } catch (VarSpec.SpecifierException se) {
            throw new MacroException(se);
        } catch (InputType.OptionException oe) {
            throw new MacroException(I18N.getText("macro.function.input.invalidOptionType", oe.key, oe.value,
                    oe.type, specifier));
        }
        varSpecs.add(vs);
    }

    // Check if any variables were defined
    if (varSpecs.isEmpty())
        return Collections.emptyMap(); // No work to do, so treat it as a successful invocation.

    // UI step 1 - First, see if a token is given

    String dialogTitle = "Input Values";
    if (token != null) {
        String name = token.getName(), gm_name = token.getGMName();
        boolean isGM = TabletopTool.getPlayer().isGM();
        String extra = "";

        if (isGM && gm_name != null && gm_name.compareTo("") != 0)
            extra = " for " + gm_name;
        else if (name != null && name.compareTo("") != 0)
            extra = " for " + name;

        dialogTitle = dialogTitle + extra;
    }

    // UI step 2 - build the panel with the input fields
    InputPanel ip = new InputPanel(varSpecs);

    // Calculate the height
    // TODO: remove this workaround
    int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
    int maxHeight = screenHeight * 3 / 4;
    Dimension ipPreferredDim = ip.getPreferredSize();
    if (maxHeight < ipPreferredDim.height) {
        ip.modifyMaxHeightBy(maxHeight - ipPreferredDim.height);
    }

    // UI step 3 - show the dialog
    JOptionPane jop = new JOptionPane(ip, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    JDialog dlg = jop.createDialog(TabletopTool.getFrame(), dialogTitle);

    // Set up callbacks needed for desired runtime behavior
    dlg.addComponentListener(new FixupComponentAdapter(ip));

    dlg.setVisible(true);
    int dlgResult = JOptionPane.CLOSED_OPTION;
    try {
        dlgResult = (Integer) jop.getValue();
    } catch (NullPointerException npe) {
    }
    dlg.dispose();

    if (dlgResult == JOptionPane.CANCEL_OPTION || dlgResult == JOptionPane.CLOSED_OPTION)
        return null;

    HashMap<String, String> results = new HashMap<String, String>();

    // Finally, assign values from the dialog box to the variables
    for (ColumnPanel cp : ip.columnPanels) {
        List<VarSpec> panelVars = cp.varSpecs;
        List<JComponent> panelControls = cp.inputFields;
        int numPanelVars = panelVars.size();
        StringBuilder allAssignments = new StringBuilder(); // holds all values assigned in this tab

        for (int varCount = 0; varCount < numPanelVars; varCount++) {
            VarSpec vs = panelVars.get(varCount);
            JComponent comp = panelControls.get(varCount);
            String newValue = null;
            switch (vs.inputType) {
            case TEXT: {
                newValue = ((JTextField) comp).getText();
                break;
            }
            case LIST: {
                Integer index = ((JComboBox) comp).getSelectedIndex();
                if (vs.optionValues.optionEquals("VALUE", "STRING")) {
                    newValue = vs.valueList.get(index);
                } else { // default is "NUMBER"
                    newValue = index.toString();
                }
                break;
            }
            case CHECK: {
                Integer value = ((JCheckBox) comp).isSelected() ? 1 : 0;
                newValue = value.toString();
                break;
            }
            case RADIO: {
                // This code assumes that the Box container returns components
                // in the same order that they were added.
                Component[] comps = ((Box) comp).getComponents();
                int componentCount = 0;
                Integer index = 0;
                for (Component c : comps) {
                    if (c instanceof JRadioButton) {
                        JRadioButton radio = (JRadioButton) c;
                        if (radio.isSelected())
                            index = componentCount;
                    }
                    componentCount++;
                }
                if (vs.optionValues.optionEquals("VALUE", "STRING")) {
                    newValue = vs.valueList.get(index);
                } else { // default is "NUMBER"
                    newValue = index.toString();
                }
                break;
            }
            case LABEL: {
                newValue = null;
                // The variable name is ignored and not set.
                break;
            }
            case PROPS: {
                // Read out and assign all the subvariables.
                // The overall return value is a property string (as in StrPropFunctions.java) with all the new settings.
                Component[] comps = ((JPanel) comp).getComponents();
                StringBuilder sb = new StringBuilder();
                int setVars = 0; // "NONE", no assignments made
                if (vs.optionValues.optionEquals("SETVARS", "SUFFIXED"))
                    setVars = 1;
                if (vs.optionValues.optionEquals("SETVARS", "UNSUFFIXED"))
                    setVars = 2;
                if (vs.optionValues.optionEquals("SETVARS", "TRUE"))
                    setVars = 2; // for backward compatibility
                for (int compCount = 0; compCount < comps.length; compCount += 2) {
                    String key = ((JLabel) comps[compCount]).getText().split("\\:")[0]; // strip trailing colon
                    String value = ((JTextField) comps[compCount + 1]).getText();
                    sb.append(key);
                    sb.append("=");
                    sb.append(value);
                    sb.append(" ; ");
                    switch (setVars) {
                    case 0:
                        // Do nothing
                        break;
                    case 1:
                        results.put(key + "_", value);
                        break;
                    case 2:
                        results.put(key, value);
                        break;
                    }
                }
                newValue = sb.toString();
                break;
            }
            default:
                // should never happen
                newValue = null;
                break;
            }
            // Set the variable to the value we got from the dialog box.
            if (newValue != null) {
                results.put(vs.name, newValue.trim());
                allAssignments.append(vs.name + "=" + newValue.trim() + " ## ");
            }
        }
        if (cp.tabVarSpec != null) {
            results.put(cp.tabVarSpec.name, allAssignments.toString());
        }
    }

    return results; // success

    // for debugging:
    //return debugOutput(varSpecs);
}

From source file:com.vsquaresystem.safedeals.readyreckoner.ReadyReckonerService.java

public Boolean checkExistingDataa() throws IOException {
    logger.info("check ke andar hai bhai??");
    Vector checkCellVectorHolder = read();
    logger.info("checkCellVectorHolder line116 :{}", checkCellVectorHolder);
    logger.info("read in check line117 :{}", read());
    int excelSize = checkCellVectorHolder.size() - 1;
    System.out.println("excelSize" + excelSize);
    List<Readyreckoner> rs = readyReckonerDAL.getAll();
    JFrame parent = new JFrame();

    System.out.println("rs" + rs);
    int listSize = rs.size();
    logger.info("rsss:::::", listSize);
    System.out.println("rsss:::::" + listSize);
    if (excelSize == listSize || excelSize > listSize) {
        JDialog.setDefaultLookAndFeelDecorated(true);
        int response = JOptionPane.showConfirmDialog(null, "Do you want to continue?", "Confirm",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        switch (response) {
        case JOptionPane.NO_OPTION:
            System.out.println("No button clicked");
            JOptionPane.showMessageDialog(parent, "upload Cancelled");
            break;
        case JOptionPane.YES_NO_OPTION:
            saveToDatabase(checkCellVectorHolder);
            System.out.println("Yes button clicked");
            JOptionPane.showMessageDialog(parent, "Saved succesfully");
            break;
        case JOptionPane.CLOSED_OPTION:
            System.out.println("JOptionPane closed");
            break;
        }//from  w  ww  .  j  av a2  s. c  om

    } else {
        System.out.println("No selected");
    }

    return true;
}

From source file:it.unibas.spicygui.controllo.mapping.ActionGenerateAndTranslate.java

private void checkForPKConstraints(MappingTask mappingTask, HashSet<String> pkTableNames, int scenarioNo)
        throws DAOException {
    if (!pkTableNames.isEmpty()) {
        NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Confirmation(
                NbBundle.getMessage(Costanti.class, Costanti.MESSAGE_PK_TABLES),
                DialogDescriptor.YES_NO_OPTION);
        DialogDisplayer.getDefault().notify(notifyDescriptor);
        if (notifyDescriptor.getValue().equals(NotifyDescriptor.YES_OPTION)) {
            String[] format = { NbBundle.getMessage(Costanti.class, Costanti.OUTPUT_TYPE_CSV),
                    NbBundle.getMessage(Costanti.class, Costanti.OUTPUT_TYPE_JSON) };
            int formatResponse = JOptionPane.showOptionDialog(null,
                    NbBundle.getMessage(Costanti.class, Costanti.MESSAGE_PK_OUTPUT),
                    NbBundle.getMessage(Costanti.class, Costanti.PK_OUTPUT_TITLE), JOptionPane.DEFAULT_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, format, format[0]);
            if (formatResponse != JOptionPane.CLOSED_OPTION) {
                JFileChooser chooser = vista.getFileChooserSalvaFolder();
                File file;/*  w ww  . j  a v  a2  s  . c o m*/
                int returnVal = chooser.showDialog(WindowManager.getDefault().getMainWindow(),
                        NbBundle.getMessage(Costanti.class, Costanti.EXPORT));
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    file = chooser.getSelectedFile();
                    if (formatResponse == 0) {
                        DAOCsv daoCsv = new DAOCsv();
                        daoCsv.exportPKConstraintCSVinstances(mappingTask, pkTableNames, file.getAbsolutePath(),
                                scenarioNo);
                        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                                NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK)));
                    } else if (formatResponse == 1) {
                        DAOJson daoJson = new DAOJson();
                        daoJson.exportPKConstraintJsoninstances(mappingTask, pkTableNames,
                                file.getAbsolutePath(), scenarioNo);
                        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                                NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK)));
                    }
                }
            }
        }
    }
}

From source file:com.sshtools.tunnel.PortForwardingPane.java

protected void editPortForward() {

    ForwardingConfiguration config = model.getForwardingConfigurationAt(table.getSelectedRow());
    if (config.getName().equals("x11")) {
        JOptionPane.showMessageDialog(this, "You cannot edit X11 forwarding.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;//w ww.  j a v  a 2s. co m
    }
    PortForwardEditorPane editor = new PortForwardEditorPane(config);

    int option = JOptionPane.showConfirmDialog(this, editor, "Edit Tunnel", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);

    if (option != JOptionPane.CANCEL_OPTION && option != JOptionPane.CLOSED_OPTION) {
        try {
            ForwardingClient forwardingClient = client;
            String id = editor.getForwardName();
            if (id.equals("x11")) {
                throw new Exception("The id of x11 is reserved.");
            }
            if (editor.getHost().equals("")) {
                throw new Exception("Please specify a destination host.");
            }
            int i = model.getRowCount();
            if (editor.isLocal()) {
                forwardingClient.removeLocalForwarding(config.getName());
                forwardingClient.addLocalForwarding(id, editor.getBindAddress(), editor.getLocalPort(),
                        editor.getHost(), editor.getRemotePort());
                forwardingClient.startLocalForwarding(id);
            } else {
                forwardingClient.removeRemoteForwarding(config.getName());
                forwardingClient.addRemoteForwarding(id, editor.getBindAddress(), editor.getLocalPort(),
                        editor.getHost(), editor.getRemotePort());
                forwardingClient.startRemoteForwarding(id);
            }

            if (i < model.getRowCount()) {
                table.getSelectionModel().addSelectionInterval(i, i);
            }
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } finally {
            model.refresh();
            sessionPanel.setAvailableActions();
        }
    }
}

From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java

private ReferenceFormat formatChooser(Collection<ReferenceFormat> formats) {
    ReferenceFormat[] formatsArray = formats.toArray(new ReferenceFormat[0]);
    String[] options = new String[formats.size()];
    for (int i = 0; i < formats.size(); i++) {
        options[i] = formatsArray[i].getDescription();
    }// ww w.  j  av  a  2  s. com
    int result = JOptionPane.showOptionDialog(frame, "Please choose a reference format.",
            "Choose a reference format", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
            options, options[0]);
    if (result == JOptionPane.CLOSED_OPTION)
        return null;
    return formatsArray[result];
}

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 ww .  ja 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();
}