Example usage for javax.swing KeyStroke getKeyStroke

List of usage examples for javax.swing KeyStroke getKeyStroke

Introduction

In this page you can find the example usage for javax.swing KeyStroke getKeyStroke.

Prototype

public static KeyStroke getKeyStroke(String s) 

Source Link

Document

Parses a string and returns a KeyStroke.

Usage

From source file:ch.epfl.lis.gnwgui.NetworkGraph.java

/**
 * Add a key listener to print the content of the JPanel in which the graph is drawn.
 * @param jp JPanel that contains the network graph.
 *//*from w w w .j  ava2 s . c o m*/
@SuppressWarnings("serial")
public void addPrintAction(JComponent jp) {
    KeyStroke k = KeyStroke.getKeyStroke("alt P");
    jp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(k, "printscreen");
    jp.getActionMap().put("printscreen", new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            item_.getNetworkViewer().getControl().printGraph();
        }
    });
}

From source file:net.sf.jabref.EntryEditor.java

/**
 * NOTE: This method is only used for the source panel, not for the
 * other tabs. Look at EntryEditorTab for the setup of text components
 * in the other tabs./*from   ww w. jav a2s. com*/
 */
private void setupJTextFieldForSourceArea(JTextComponent ta) {
    setupSwingComponentKeyBindings(ta);

    // HashSet<AWTKeyStroke> keys = new HashSet<AWTKeyStroke>(ta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));          
    HashSet<AWTKeyStroke> keys = new HashSet<AWTKeyStroke>();
    keys.add(AWTKeyStroke.getAWTKeyStroke("pressed TAB"));
    ta.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);

    // keys = new HashSet<AWTKeyStroke>(ta.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
    keys = new HashSet<AWTKeyStroke>();
    keys.add(KeyStroke.getKeyStroke("shift pressed TAB"));
    ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys);

    ta.addFocusListener(new FieldListener());
}

From source file:com.osparking.attendant.AttListForm.java

/**
 * Creates new form AttListForm/*  w  ww.  j a  va  2  s.c o m*/
 */
public AttListForm(IMainGUI mainGUI, String loginID, String loginPW, boolean isManager) {
    // Mark the first row as selected in default
    this.mainGUI = mainGUI;

    try {
        initComponents();
        setLocation(0, 0);
        setIconImages(OSPiconList);

        // Reset search column combobox items
        searchCriteriaComboBox.removeAllItems();
        searchCriteriaComboBox.addItem(new ConvComboBoxItem(LOGIN_ID_LABEL, LOGIN_ID_LABEL.getContent()));
        searchCriteriaComboBox.addItem(new ConvComboBoxItem(NAME_LABEL, NAME_LABEL.getContent()));

        // Make last 8 digits of the user ID visible on the user password label.
        String id = loginID;
        if (loginID.length() > 8) {
            id = ".." + loginID.substring(loginID.length() - 8);
        }
        userPWLabel.setText(id + " " + MY_PW_LABEL.getContent());

        this.loginID = loginID;
        this.loginPW = loginPW;
        this.isManager = isManager;
        initComponentsUser();

        // limit maximun allowed length of user IDa
        userIDText.setDocument(new JTextFieldLimit(20));

        ListSelectionModel model = usersTable.getSelectionModel();
        model.addListSelectionListener(new AttendantRowSelectionListener());

        setFormMode(FormMode.NormalMode);
        loadAttendantTable("");

        int selectIndex = searchRow(loginID);

        if (rowHidden(usersTable, selectIndex)) {
            usersTable.changeSelection(selectIndex, 0, false, false);
        } else {
            usersTable.setRowSelectionInterval(selectIndex, selectIndex);
        }

        usersTable.requestFocus();
        usersTable.getRowSorter().addRowSorterListener(new RowSorterListener() {
            @Override
            public void sorterChanged(final RowSorterEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        if (e.getType() == RowSorterEvent.Type.SORTED) {
                            if (usersTable.getSelectedRow() != -1) {
                                usersTable.scrollRectToVisible(
                                        usersTable.getCellRect(usersTable.getSelectedRow(), 0, false));
                            }
                        }
                    }
                });
            }
        });
    } catch (Exception ex) {
        logParkingException(Level.SEVERE, ex, "(AttListForm Constructor ID: " + loginID + ")");
    }

    JComponent pane = (JComponent) this.getContentPane();
    pane.getInputMap().put(null, MUTEX_DEBUG_SEQ_VALUE);

    addWindowListener(new WindowAdapter() {
        public void windowOpened(WindowEvent e) {
            searchText.requestFocus();
        }
    });
    attachEnterHandler(searchText);
    adminAuth2CheckBox.setSelected(isManager);

    KeyStroke controlF = KeyStroke.getKeyStroke("control F");
    JRootPane rootPane = getRootPane();
    rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(controlF, "myAction");
    rootPane.getActionMap().put("myAction", new Ctrl_F_Action(searchText));
}

From source file:net.schweerelos.parrot.CombinedParrotApp.java

@SuppressWarnings("serial")
private JToggleButton setupNavigatorButton(final String name, final String accelerator,
        final NavigatorComponent navigator) {
    final Component component = navigator.asJComponent();
    AbstractAction showNavigatorAction = new AbstractAction(name) {
        @Override//from   w  w w. ja v  a 2  s .com
        public void actionPerformed(ActionEvent e) {
            if (!(e.getSource() instanceof JToggleButton)) {
                return;
            }
            final Window window;
            if (component instanceof Window) {
                window = (Window) component;
            } else {
                window = SwingUtilities.getWindowAncestor(component);
            }
            JToggleButton button = (JToggleButton) e.getSource();
            boolean show = button.isSelected();
            if (show) {
                if (window != CombinedParrotApp.this && preferredFrameLocations.containsKey(window)) {
                    window.setLocation(preferredFrameLocations.get(window));
                }
            }
            if (navigator.tellSelectionWhenShown()) {
                Collection<NodeWrapper> selectedNodes = activeMainView.getSelectedNodes();
                navigator.setSelectedNodes(selectedNodes);
            }
            component.setVisible(show);
            if (show) {
                window.setVisible(true);
            } else if (window != CombinedParrotApp.this) {
                window.setVisible(false);
            }
        }
    };
    showNavigatorAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control " + accelerator));
    final JToggleButton button = new JToggleButton(showNavigatorAction);
    button.setToolTipText("Show " + name.toLowerCase());
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button.setToolTipText((button.isSelected() ? "Hide " : "Show ") + name.toLowerCase());
        }
    });
    final Window window;
    if (component instanceof Window) {
        window = (Window) component;
    } else {
        window = SwingUtilities.getWindowAncestor(component);
    }
    if (window != null) {
        window.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentHidden(ComponentEvent e) {
                button.setSelected(false);
                if (window != CombinedParrotApp.this) {
                    preferredFrameLocations.put(window, window.getLocation());
                }
            }

            @Override
            public void componentShown(ComponentEvent e) {
                button.setSelected(true);
            }
        });
    }
    return button;
}

From source file:com.osparking.attendant.AttListForm.java

private void attachEnterHandler(JComponent compo) {
    Action handleEnter = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            searchButtonActionPerformed(null);
        }//from   w w  w.jav  a2s.  c  om
    };
    compo.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "handleEnter");
    compo.getActionMap().put("handleEnter", handleEnter);
}

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

private JMenuBar createMenuBar() {
    JMenuBar bar = new JMenuBar();
    JMenu menu = null;/*from   ww w.ja v  a2s  .  co m*/
    /*
     * 'File' Menue
     */
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    bar.add(menu);

    JMenuItem item = new JMenuItem("Save database");
    item.setAccelerator(KeyStroke.getKeyStroke("control S"));
    item.setMnemonic(KeyEvent.VK_S);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveDatabase();
        }
    });
    menu.add(item);

    item = new JMenuItem("Download database");
    item.setMnemonic(KeyEvent.VK_L);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            downloadAndMergeData();
        }
    });
    menu.add(item);

    item = new JMenuItem("Edit sync account");
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            editSyncAccount();
        }
    });
    menu.add(item);
    menu.add(new JSeparator());

    JMenu submenu = new JMenu("Import");
    menu.add(submenu);

    item = new JMenuItem("From CSV");
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            importCSV();
        }
    });
    submenu.add(item);

    submenu = new JMenu("Export");
    menu.add(submenu);

    item = new JMenuItem("As CSV");
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            exportCSV();
        }
    });
    submenu.add(item);
    item = new JMenuItem("Change passphrase");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changePassword();
        }
    });

    /*
     * 'Edit' Menue
     */
    menu = new JMenu("Edit");
    menu.setMnemonic(KeyEvent.VK_E);
    bar.add(menu);
    item = menu.add(mainPanel.getNewEntryAction());
    item.setMnemonic(KeyEvent.VK_N);
    item = menu.add(mainPanel.getDeleteEntryAction());
    item.setMnemonic(KeyEvent.VK_D);

    menu.add(new JSeparator());

    menu = new JMenu("Tools");
    // item = new JMenuItem("Passwort generator");
    // menu.add(item);
    // item.addActionListener(new ActionListener() {
    //
    // @Override
    // public void actionPerformed(ActionEvent e) {
    // passGenerator.setVisible(false);
    // passGenerator.setLocationRelativeTo(getMainFrame());
    // passGenerator.setVisible(true);
    // }
    // });
    item = new JMenuItem("Screen keyboard");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            screenKeyboard.setLocationRelativeTo(getMainFrame());
            screenKeyboard.setVisible(true);

        }
    });
    item = new JMenuItem("File digester");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            digester.setLocationRelativeTo(getMainFrame());
            digester.setVisible(true);

        }
    });
    bar.add(menu);
    /*
     * 'Help' Menue
     */
    menu = new JMenu("Help");
    menu.setMnemonic(KeyEvent.VK_H);
    bar.add(menu);

    item = new JMenuItem("Performance test");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            measurePerformance();
        }
    });
    item = new JMenuItem("System info");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showSystemInfo();
        }
    });
    item = new JMenuItem("About");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String text = "<html>Ultracipher 6.1<br>(C) Copyright 2015 Paul Burlov<br><br>"
                    + "Encryption strength: 768Bit (6 x 128Bit keys)<br>Cipher cascade: AES/Twofish/Serpent/CAST6/SEED/Camellia"
                    + "<br>Encryption mode: Two pass CBC"
                    + "<br>Key derivation algorithm: SCrypt with N=2^14,P=8,R=1<br><br> "
                    + "This product includes software developed by the<br>"
                    + "<ul><li>Apache Software Foundation "
                    + "<a href='http://www.apache.org'>http://www.apache.org</a>"
                    + "<li>Legion of the Bouncy Castle <a href='http://bouncycastle.org/'>http://bouncycastle.org</a>"
                    + "<li>Project SwingX" + "<li>Bytecode Pty Ltd." + "</ul></html>";
            JOptionPane.showMessageDialog(getMainFrame(), text, "", JOptionPane.INFORMATION_MESSAGE,
                    getAppIcon());
        }
    });
    bar.add(Box.createHorizontalGlue());
    menu = new JMenu("Keyboard");
    ButtonGroup group = new ButtonGroup();
    JRadioButtonMenuItem radioitem = new JRadioButtonMenuItem("System");
    radioitem.setSelected(true);
    group.add(radioitem);
    radioitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            translator.resetMapping();
        }
    });
    menu.add(radioitem);
    radioitem = new JRadioButtonMenuItem("Futhark runes");
    group.add(radioitem);
    radioitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            translator.initForFuthark();
        }
    });
    menu.add(radioitem);
    radioitem = new JRadioButtonMenuItem("Anglo-Saxon runes");
    group.add(radioitem);
    radioitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            translator.initForAngloSaxon();
        }
    });
    menu.add(radioitem);
    bar.add(menu);
    // bar.add(Box.createHorizontalGlue());
    // bar.add(new PassGeneratorPanel());
    return bar;
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

/**
 * Creates new form JTicketView/*from   ww w  .  ja v  a 2s.  c o m*/
 */
public JRetailPanelTakeAway() {
    initComponents();

    tnbbutton = new ThumbNailBuilderPopularItems(110, 57, "com/openbravo/images/bluetoit.png");
    TextListener txtL;
    // cusName = (JTextField) m_jCboCustName.getEditor().getEditorComponent();
    // cusPhoneNo= (JTextField) m_jCboContactNo.getEditor().getEditorComponent();
    itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent();
    m_jTxtItemCode.setFocusable(true);
    // m_jTxtCustomerId.setFocusable(true);
    txtL = new TextListener();
    // m_jCreditAllowed.setVisible(false);
    // m_jCreditAllowed.setSelected(false);
    //       cusPhoneNo.addFocusListener(txtL);
    //cusName.addFocusListener(txtL);

    itemName.addFocusListener(txtL);
    Action doMorething = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //    m_jPrice.setEnabled(true);
            //     m_jPrice.setFocusable(true);
            m_jKeyFactory.setFocusable(true);
            m_jKeyFactory.setText(null);
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    m_jKeyFactory.requestFocus();
                }
            });

        }
    };

    //        InputMap imap = m_jPrice.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

    //     imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK), "doMorething");
    //    m_jPrice.getActionMap().put("doMorething",doMorething);

    //   Action doLastBill = new AbstractAction() {
    //   public void actionPerformed(ActionEvent e) {
    //        m_jLastBillActionPerformed(e);
    //        stateToZero();
    //       }
    //   };

    //   InputMap imapLastBill = m_jLastBill.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    //  imapLastBill.put(KeyStroke.getKeyStroke("F7"), "doLastBill");
    //  m_jLastBill.getActionMap().put("doLastBill",doLastBill);

    Action cashNoBill = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //  cashPayment(3);
            //  setPrinterOn();
        }
    };
    InputMap imapCashNoBill = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

    imapCashNoBill.put(KeyStroke.getKeyStroke("F1"), "cashNoBill");
    m_jAction.getActionMap().put("cashNoBill", cashNoBill);
    // };
    Action cashReceipt = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //   cashPayment(2);
        }
    };
    InputMap imapCashReceipt = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapCashReceipt.put(KeyStroke.getKeyStroke("F2"), "cashReceipt");
    m_jAction.getActionMap().put("cashReceipt", cashReceipt);

    Action docashPrint = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //  cashPayment(1);
        }
    };

    InputMap imapCashPrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapCashPrint.put(KeyStroke.getKeyStroke("F3"), "docashPrint");
    m_jAction.getActionMap().put("docashPrint", docashPrint);
    Action doCardnobill = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //m_jCloseShiftActionPerformed(e);
            //     cardPayment(1);
        }
    };

    InputMap imapCardnoBill = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapCardnoBill.put(KeyStroke.getKeyStroke("F4"), "doCardnobill");
    m_jAction.getActionMap().put("doCardnobill", doCardnobill);

    Action doNonChargablePrint = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            try {
                closeTicketNonChargable(m_oTicket, m_oTicketExt, m_aPaymentInfo);
            } catch (BasicException ex) {
                logger.info("exception in closeTicketNonChargable" + ex.getMessage());
                Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    };

    InputMap imapNonChargablePrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapNonChargablePrint.put(KeyStroke.getKeyStroke("F7"), "doNonChargablePrint");
    m_jAction.getActionMap().put("doNonChargablePrint", doNonChargablePrint);

    Action doCreditreceipt = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //            m_jCreditAmount.setText(Double.toString(m_oTicket.getTotal()));
            //
            //            try {
            //                    closeCreditTicket(m_oTicket, m_oTicketExt, m_aPaymentInfo);
            //                } catch (BasicException ex) {
            //                    Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
            //                }
        }
    };
    InputMap imapCreditReceipt = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapCreditReceipt.put(KeyStroke.getKeyStroke("F5"), "doCreditreceipt");
    m_jAction.getActionMap().put("doCreditreceipt", doCreditreceipt);

    Action doHomeDeliveryNotPaid = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            // m_jHomeDelivery.setSelected(true);
            if (getEditSale() == "Edit") {
                //  getServiceCharge("Y");
                printPartialTotals();
                try {
                    closeTicketHomeDelivery(m_oTicket, m_oTicketExt, m_aPaymentInfo);
                } catch (BasicException ex) {
                    logger.info("exception in closeTicketHomeDelivery" + ex.getMessage());
                    Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    };

    InputMap imapCardPrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapCardPrint.put(KeyStroke.getKeyStroke("F6"), "doHomeDeliveryNotPaid");
    m_jAction.getActionMap().put("doHomeDeliveryNotPaid", doHomeDeliveryNotPaid);

    Action doLogout = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            m_jLogoutActionPerformed(e);

        }
    };

    InputMap imapLog = m_jLogout.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapLog.put(KeyStroke.getKeyStroke("F12"), "doLogout");
    m_jLogout.getActionMap().put("doLogout", doLogout);

    Action doupArrow = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //                m_jUpActionPerformed(e);
        }
    };
    InputMap imapUpArrow = m_jPlus.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapUpArrow.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "doupArrow");
    m_jPlus.getActionMap().put("doupArrow", doupArrow);

    //       Action doCustomer = new AbstractAction() {
    //       public void actionPerformed(ActionEvent e) {
    //
    ////              m_jTxtCustomerId.setFocusable(true);
    //
    //        //    cusPhoneNo.setFocusable(true);
    //       //     cusName.setFocusable(true);
    //            stateToBarcode();
    //            }
    //        };

    //        InputMap imapCustomer= m_jTxtCustomerId.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    //        imapCustomer.put(KeyStroke.getKeyStroke("F8"), "doCustomer");
    //        m_jTxtCustomerId.getActionMap().put("doCustomer",
    //                doCustomer);

    Action doItem = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            itemName.setFocusable(true);
            m_jTxtItemCode.setFocusable(true);
            stateToItem();

        }
    };

    InputMap imapItem = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapItem.put(KeyStroke.getKeyStroke("F9"), "doItem");
    m_jAction.getActionMap().put("doItem", doItem);

    //        Action doHomeDelivery = new AbstractAction() {
    //       public void actionPerformed(ActionEvent e) {
    ////            m_jHomeDelivery.setFocusable(true);
    //        //    m_jHomeDelivery.setSelected(true);
    //      //      m_jHomeDeliveryActionPerformed(e);
    //      //      m_jTxtAdvance.setFocusable(true);
    //            stateToHomeDelivery();
    //            }
    //        };
    //
    //        InputMap imapHomeDelivery= m_jHomeDelivery.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    //        imapHomeDelivery.put(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.ALT_MASK), "doHomeDelivery");
    //        m_jHomeDelivery.getActionMap().put("doHomeDelivery",
    //                doHomeDelivery);
    //

    Action doPayment = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //           m_jCash.setFocusable(true);
            //       m_jCard.setFocusable(true);
            //       m_jCheque.setFocusable(true);
            //       m_jtxtChequeNo.setFocusable(true);
            //       m_jFoodCoupon.setFocusable(true);
            //      m_jVoucher.setFocusable(true);
            //      m_jCreditAmount.setFocusable(true);
            stateToPayment();
        }
    };

    InputMap imapPayment = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapPayment.put(KeyStroke.getKeyStroke("F11"), "doPayment");
    m_jAction.getActionMap().put("doPayment", doPayment);

    Action doDownpArrow = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //               m_jDownActionPerformed(e);
        }
    };

    InputMap imapArrow = m_jMinus.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    imapArrow.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "doDownpArrow");
    m_jMinus.getActionMap().put("doDownpArrow", doDownpArrow);

    itemName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (!itemName.getText().equals("") || !itemName.getText().equals(null)) {

                incProductByItemDetails(pdtId);
                //  itemName.setText("");
                //          m_jCboItemName.setSelectedIndex(-1);

                ArrayList<String> itemCode = new ArrayList<String>();
                ArrayList<String> itemName1 = new ArrayList<String>();

                vItemName.removeAllElements();
                try {
                    productListDetails = (ArrayList<ProductInfoExt>) dlSales.getProductDetails();
                } catch (BasicException ex) {
                    Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
                }

                for (ProductInfoExt product : productListDetails) {
                    itemCode.add(product.getItemCode());
                    itemName1.add(product.getName());
                }

                String[] productName = itemName1.toArray(new String[itemName1.size()]);

                for (int i = 0; i < itemName1.size(); i++) {
                    vItemName.addElement(productName[i]);
                }
                itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent();

            } else {
                pdtId = "";
                ArrayList<String> itemCode = new ArrayList<String>();
                ArrayList<String> itemName1 = new ArrayList<String>();

                vItemName.removeAllElements();
                try {
                    productListDetails = (ArrayList<ProductInfoExt>) dlSales.getProductDetails();
                } catch (BasicException ex) {
                    Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
                }

                for (ProductInfoExt product : productListDetails) {
                    itemCode.add(product.getItemCode());
                    itemName1.add(product.getName());
                }

                String[] productName = itemName1.toArray(new String[itemName1.size()]);
                for (int i = 0; i < itemName1.size(); i++) {
                    vItemName.addElement(productName[i]);
                }
                itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent();

            }
        }
    });

}

From source file:edu.ku.brc.af.ui.forms.FormViewObj.java

/**
 * Constructor with FormView definition.
 * @param view the definition of the view
 * @param altView indicates which AltViewIFace we will be using
 * @param mvParent the mvParent mulitview
 * @param formValidator the form's formValidator
 * @param options the options needed for creating the form
 * @param cellName the name of the outer form's cell for this view (subview)
 * @param bgColor bg color it should use
 *///  www  .j a va  2  s . c  om
public FormViewObj(final ViewIFace view, final AltViewIFace altView, final MultiView mvParent,
        final FormValidator formValidator, final int options, final String cellName, final Class<?> dataClass,
        final Color bgColor) {
    this.view = view;
    this.altView = altView;
    this.mvParent = mvParent;
    this.cellName = cellName;
    this.dataClass = dataClass;
    this.bgColor = bgColor;

    businessRules = view.createBusinessRule();

    //XXX bug #9497: isEditing        = altView.getMode() == AltViewIFace.CreationMode.EDIT && MultiView.isOptionOn(options, MultiView.IS_EDITTING);
    isEditing = altView.getMode() == AltViewIFace.CreationMode.EDIT;

    boolean addSearch = mvParent != null
            && MultiView.isOptionOn(mvParent.getOptions(), MultiView.ADD_SEARCH_BTN);
    if (addSearch) {
        isEditing = false;
    }
    this.formViewDef = (FormViewDef) altView.getViewDef();

    // Figure columns
    try {
        JPanel panel = useDebugForm ? new FormDebugPanel() : (restrictablePanel = new RestrictablePanel());
        formLayout = new FormLayout(formViewDef.getColumnDef(), formViewDef.getRowDef());
        builder = new PanelBuilder(formLayout, panel);

    } catch (java.lang.NumberFormatException ex) {
        String msg = "Error in row or column definition for form: `" + view.getName() + "`\n" + ex.getMessage();
        UIRegistry.showError(msg);
        return;
    }

    mainComp = new JPanel(new BorderLayout());
    mainComp.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    if (mvParent == null) {
        builder.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    }
    if (bgColor != null) {
        builder.getPanel().setBackground(bgColor);
    }

    this.options = options;
    boolean isSingleObj = MultiView.isOptionOn(options, MultiView.IS_SINGLE_OBJ);
    boolean createResultSetController = MultiView.isOptionOn(options, MultiView.RESULTSET_CONTROLLER);
    boolean hideResultSetController = MultiView.isOptionOn(options, MultiView.HIDE_RESULTSET_CONTROLLER);
    boolean createViewSwitcher = MultiView.isOptionOn(options, MultiView.VIEW_SWITCHER);
    //boolean isNewObject                = MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT);
    boolean hideSaveBtn = MultiView.isOptionOn(options, MultiView.HIDE_SAVE_BTN);

    isNewlyCreatedDataObj = MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT);
    if (formValidator != null) {
        formValidator.setNewObj(isNewlyCreatedDataObj);
    }

    //MultiView.printCreateOptions("Creating Form "+altView.getName(), options);

    setValidator(formValidator);

    scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting", "scrdateformat");

    AppPreferences.getRemote().addChangeListener("ui.formatting.viewfieldcolor", this);

    boolean addController = mvParent != null && view.getAltViews().size() > 1;

    // See if we need to add a Selector ComboBox
    isSelectorForm = StringUtils.isNotEmpty(view.getSelectorName());

    boolean addSelectorCBX = false;
    //log.debug(altView.getName()+"  "+altView.getMode()+"  "+AltViewIFace.CreationMode.EDIT);
    //if (isSelectorForm && isNewObject && altView.getMode() == AltViewIFace.CreationMode.EDIT)
    if (isSelectorForm && altView.getMode() == AltViewIFace.CreationMode.EDIT) {
        addSelectorCBX = true;
    }

    List<JComponent> comps = new ArrayList<JComponent>();

    int y = 1;
    // Here we create the JComboBox that enables the user to switch between forms
    // when creating a new object
    if (addSelectorCBX) {
        Vector<AltViewIFace> cbxList = new Vector<AltViewIFace>();
        cbxList.add(altView);
        for (AltViewIFace av : view.getAltViews()) {
            if (av != altView && av.getMode() == AltViewIFace.CreationMode.EDIT) {
                cbxList.add(av);
            }
        }
        JPanel p = new JPanel(new BorderLayout());
        p.setOpaque(false);

        p.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        selectorCBX = createComboBox(cbxList);
        selectorCBX.setRenderer(new SelectorCellRenderer());
        p.add(selectorCBX, BorderLayout.WEST);
        mainComp.add(p, BorderLayout.NORTH);

        if (mvParent != null) {
            selectorCBX.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ev) {
                    doSelectorWasSelected(mvParent, ev);
                }
            });
        }
        y += 2;
    }

    //
    // We will add the switchable UI if we are parented to a MultiView and have multiple AltViews
    //
    if (addController) // this says we are the "root" form
    {
        boolean saveWasAdded = false;

        // We want it on the left side of other buttons
        // so wee need to add it before the Save button
        JComponent valInfoBtn = createValidationIndicator(getUIComponent(), formValidator);
        if (valInfoBtn != null) {
            comps.add(valInfoBtn);
        }

        if (createViewSwitcher) // This is passed in outside
        {
            // Now we have a Special case that when when there are only two AltViews and
            // they differ only by Edit & View we hide the switching UI unless we are the root MultiView.
            // This way when switching the Root View all the other views switch
            // (This is because they were created that way. It also makes no sense that while in "View" mode
            // you would want to switch an individual subview to a differe "mode" view than the root).

            altViewsList = new Vector<AltViewIFace>();

            // This will return null if it isn't suppose to have a switcher
            switcherUI = createMenuSwitcherPanel(mvParent, view, altView, altViewsList, restrictablePanel,
                    cellName, dataClass);

            Action action = new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (switcherUI != null && switcherUI.getSwitcherAL() != null) {
                        switcherUI.getSwitcherAL().actionPerformed(e);
                    }
                }
            };

            if (restrictablePanel != null) {
                restrictablePanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
                        .put(KeyStroke.getKeyStroke("control E"), actionName);
                restrictablePanel.getActionMap().put(actionName, action);
            }

            if (altViewsList.size() > 0) {
                if (altView.getMode() == AltViewIFace.CreationMode.EDIT && mvParent != null
                        && mvParent.isTopLevel()) {
                    addSaveBtn();
                    comps.add(saveControl);
                    saveWasAdded = true;
                }

                if (switcherUI != null) {
                    comps.add(switcherUI);

                }
            }

            // rods - 07/21/08 for disabling the switcher when the form is invalid 
            if (formValidator != null && switcherUI != null) {
                formValidator.addEnableItem(switcherUI, FormValidator.EnableType.ValidNotNew);
            }
        }

        if (!saveWasAdded && altView.getMode() == AltViewIFace.CreationMode.EDIT && mvParent != null
                && mvParent.isTopLevel() && !hideSaveBtn) {
            addSaveBtn();
            comps.add(saveControl);
        }
    }

    // This here because the Search mode shouldn't be combined with other modes
    if (altView.getMode() == AltViewIFace.CreationMode.SEARCH) {
        if (!hideSaveBtn) {
            saveControl = createButton(UIRegistry.getResourceString("SEARCH"),
                    IconManager.getImage("Search", IconManager.IconSize.Std16));/*
                                                                                {
                                                                                public void setEnabled(boolean enabled)
                                                                                {
                                                                                System.err.println("Save: "+enabled);
                                                                                super.setEnabled(enabled);
                                                                                }
                                                                                };*/
            saveControl.setOpaque(false);
            comps.add(saveControl);

            addSaveActionMap(saveControl);
        }

    }

    if (ViewFactory.isFormTransparent()) {
        builder.getPanel().setOpaque(false);
    }
    mainComp.add(builder.getPanel(), BorderLayout.CENTER);

    if (comps.size() > 0 || addController || createResultSetController) {
        controlPanel = new ControlBarPanel(bgColor);
        controlPanel.addComponents(comps, false); // false -> right side

        if (ViewFactory.isFormTransparent()) {
            controlPanel.setOpaque(false);
        }

        mainComp.add(controlPanel, BorderLayout.SOUTH);

    }

    if (createResultSetController) {
        addRSController(addSearch);
        if (hideResultSetController) {
            rsController.getPanel().setVisible(false);
        }
        if (addSearch) {
            DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByClassName(view.getClassName());
            if (tblInfo != null) {
                searchName = tblInfo.getSearchDialog();
                if (StringUtils.isEmpty(searchName)) {
                    searchName = ""; // Note not null but empty tells it to disable the search btn

                    log.error("The Search Dialog Name is empty or missing for class[" + view.getClassName()
                            + "]");
                }
            } else {
                log.error("Couldn't find TableInfo for class[" + view.getClassName() + "]");
            }

            if (rsController.getSearchRecBtn() != null) {
                rsController.getSearchRecBtn().setEnabled(true);
                rsController.getSearchRecBtn().addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        doSearch();
                    }
                });
            }
        }

    } else if (isSingleObj) {
        createAddDelSearchPanel();
    }

    if (true) {
        builder.getPanel().addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                showContextMenu(e);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                showContextMenu(e);

            }

            @Override
            public void mouseClicked(MouseEvent e) {
                //FormViewObj.this.listFieldChanges();
            }
        });
    }

    if (rsController != null) {
        rsController.setNewObj(isNewlyCreatedDataObj);
    }

    isBuildValid = true;

    isAutoNumberOn = AppPreferences.getLocalPrefs().getBoolean(AUTO_NUM, true);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            updateAutoNumberFieldState();
        }
    });
}

From source file:net.sf.jabref.gui.entryeditor.EntryEditor.java

/**
 * NOTE: This method is only used for the source panel, not for the
 * other tabs. Look at EntryEditorTab for the setup of text components
 * in the other tabs.//w w  w.  jav a  2  s . co  m
 */
private void setupJTextComponent(JTextComponent textComponent) {
    // Set up key bindings and focus listener for the FieldEditor.
    InputMap inputMap = textComponent.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = textComponent.getActionMap();

    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store");
    actionMap.put("store", getStoreFieldAction());

    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_PANEL), "right");
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_PANEL_2), "right");
    actionMap.put("right", getSwitchRightAction());

    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_PANEL), "left");
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_PANEL_2), "left");
    actionMap.put("left", getSwitchLeftAction());

    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help");
    actionMap.put("help", getHelpAction());
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.SAVE_DATABASE), "save");
    actionMap.put("save", getSaveDatabaseAction());

    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.NEXT_TAB), "nexttab");
    actionMap.put("nexttab", frame.nextTab);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.PREVIOUS_TAB), "prevtab");
    actionMap.put("prevtab", frame.prevTab);

    Set<AWTKeyStroke> keys = new HashSet<>(
            textComponent.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    keys.clear();
    keys.add(AWTKeyStroke.getAWTKeyStroke("pressed TAB"));
    textComponent.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);
    keys = new HashSet<>(textComponent.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
    keys.clear();
    keys.add(KeyStroke.getKeyStroke("shift pressed TAB"));
    textComponent.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys);

    textComponent.addFocusListener(new FieldListener());
}

From source file:davmail.ui.SettingsFrame.java

/**
 * DavMail settings frame.//  w w  w  .  j  a v  a  2s.c om
 */
public SettingsFrame() {
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setTitle(BundleMessage.format("UI_DAVMAIL_SETTINGS"));
    try {
        setIconImage(DavGatewayTray.getFrameIcon());
    } catch (NoSuchMethodError error) {
        DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_SET_ICON_IMAGE"));
    }

    JTabbedPane tabbedPane = new JTabbedPane();
    // add help (F1 handler)
    tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F1"),
            "help");
    tabbedPane.getActionMap().put("help", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            DesktopBrowser.browse("http://davmail.sourceforge.net");
        }
    });
    tabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            boolean isSslEnabled = isSslEnabled();
            popNoSSLCheckBox.setEnabled(Settings.getProperty("davmail.popPort") != null && isSslEnabled);
            imapNoSSLCheckBox.setEnabled(imapPortCheckBox.isSelected() && isSslEnabled);
            smtpNoSSLCheckBox.setEnabled(smtpPortCheckBox.isSelected() && isSslEnabled);
            caldavNoSSLCheckBox.setEnabled(caldavPortCheckBox.isSelected() && isSslEnabled);
            ldapNoSSLCheckBox.setEnabled(ldapPortCheckBox.isSelected() && isSslEnabled);
        }
    });

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(getSettingsPanel());
    mainPanel.add(getDelaysPanel());
    mainPanel.add(Box.createVerticalGlue());

    tabbedPane.add(BundleMessage.format("UI_TAB_MAIN"), mainPanel);

    JPanel proxyPanel = new JPanel();
    proxyPanel.setLayout(new BoxLayout(proxyPanel, BoxLayout.Y_AXIS));
    proxyPanel.add(getProxyPanel());
    proxyPanel.add(getNetworkSettingsPanel());
    tabbedPane.add(BundleMessage.format("UI_TAB_NETWORK"), proxyPanel);

    JPanel encryptionPanel = new JPanel();
    encryptionPanel.setLayout(new BoxLayout(encryptionPanel, BoxLayout.Y_AXIS));
    encryptionPanel.add(getKeystorePanel());
    encryptionPanel.add(getSmartCardPanel());
    // empty panel
    encryptionPanel.add(new JPanel());
    tabbedPane.add(BundleMessage.format("UI_TAB_ENCRYPTION"), encryptionPanel);

    JPanel loggingPanel = new JPanel();
    loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS));
    loggingPanel.add(getLoggingSettingsPanel());
    // empty panel
    loggingPanel.add(new JPanel());

    tabbedPane.add(BundleMessage.format("UI_TAB_LOGGING"), loggingPanel);

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

    advancedPanel.add(getOtherSettingsPanel());
    // empty panel
    advancedPanel.add(new JPanel());

    tabbedPane.add(BundleMessage.format("UI_TAB_ADVANCED"), advancedPanel);

    if (OSXInfoPlist.isOSX()) {
        JPanel osxPanel = new JPanel();
        osxPanel.setLayout(new BoxLayout(osxPanel, BoxLayout.Y_AXIS));
        osxPanel.add(getOSXPanel());
        // empty panel
        osxPanel.add(new JPanel());

        tabbedPane.add(BundleMessage.format("UI_TAB_OSX"), osxPanel);
    }

    add(BorderLayout.CENTER, tabbedPane);

    JPanel buttonPanel = new JPanel();
    JButton cancel = new JButton(BundleMessage.format("UI_BUTTON_CANCEL"));
    JButton ok = new JButton(BundleMessage.format("UI_BUTTON_SAVE"));
    JButton help = new JButton(BundleMessage.format("UI_BUTTON_HELP"));
    ActionListener save = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            // save options
            Settings.setProperty("davmail.url", urlField.getText());
            Settings.setProperty("davmail.popPort", popPortCheckBox.isSelected() ? popPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecurepop", String.valueOf(popNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.imapPort",
                    imapPortCheckBox.isSelected() ? imapPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecureimap", String.valueOf(imapNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.smtpPort",
                    smtpPortCheckBox.isSelected() ? smtpPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecuresmtp", String.valueOf(smtpNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.caldavPort",
                    caldavPortCheckBox.isSelected() ? caldavPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecurecaldav",
                    String.valueOf(caldavNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.ldapPort",
                    ldapPortCheckBox.isSelected() ? ldapPortField.getText() : "");
            Settings.setProperty("davmail.ssl.nosecureldap", String.valueOf(ldapNoSSLCheckBox.isSelected()));
            Settings.setProperty("davmail.keepDelay", keepDelayField.getText());
            Settings.setProperty("davmail.sentKeepDelay", sentKeepDelayField.getText());
            Settings.setProperty("davmail.caldavPastDelay", caldavPastDelayField.getText());
            Settings.setProperty("davmail.imapIdleDelay", imapIdleDelayField.getText());
            Settings.setProperty("davmail.useSystemProxies",
                    String.valueOf(useSystemProxiesField.isSelected()));
            Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected()));
            Settings.setProperty("davmail.proxyHost", httpProxyField.getText());
            Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText());
            Settings.setProperty("davmail.proxyUser", httpProxyUserField.getText());
            Settings.setProperty("davmail.proxyPassword", httpProxyPasswordField.getText());
            Settings.setProperty("davmail.noProxyFor", noProxyForField.getText());

            Settings.setProperty("davmail.bindAddress", bindAddressField.getText());
            Settings.setProperty("davmail.clientSoTimeout", String.valueOf(clientSoTimeoutField.getText()));
            Settings.setProperty("davmail.allowRemote", String.valueOf(allowRemoteField.isSelected()));
            Settings.setProperty("davmail.server.certificate.hash", certHashField.getText());
            Settings.setProperty("davmail.disableUpdateCheck", String.valueOf(disableUpdateCheck.isSelected()));

            Settings.setProperty("davmail.caldavEditNotifications",
                    String.valueOf(caldavEditNotificationsField.isSelected()));
            Settings.setProperty("davmail.caldavAlarmSound", String.valueOf(caldavAlarmSoundField.getText()));
            Settings.setProperty("davmail.forceActiveSyncUpdate",
                    String.valueOf(forceActiveSyncUpdateCheckBox.isSelected()));
            Settings.setProperty("davmail.defaultDomain", String.valueOf(defaultDomainField.getText()));
            Settings.setProperty("davmail.showStartupBanner",
                    String.valueOf(showStartupBannerCheckBox.isSelected()));
            Settings.setProperty("davmail.disableGuiNotifications",
                    String.valueOf(disableGuiNotificationsCheckBox.isSelected()));
            Settings.setProperty("davmail.imapAutoExpunge",
                    String.valueOf(imapAutoExpungeCheckBox.isSelected()));
            Settings.setProperty("davmail.popMarkReadOnRetr",
                    String.valueOf(popMarkReadOnRetrCheckBox.isSelected()));
            String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem();
            String enableEws;
            if (EWS.equals(selectedEwsMode)) {
                enableEws = "true";
            } else if (WEBDAV.equals(selectedEwsMode)) {
                enableEws = "false";
            } else {
                enableEws = "auto";
            }
            Settings.setProperty("davmail.enableEws", enableEws);
            Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected()));

            Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem());
            Settings.setProperty("davmail.ssl.keystoreFile", keystoreFileField.getText());
            Settings.setProperty("davmail.ssl.keystorePass", String.valueOf(keystorePassField.getPassword()));
            Settings.setProperty("davmail.ssl.keyPass", String.valueOf(keyPassField.getPassword()));

            Settings.setProperty("davmail.ssl.clientKeystoreType",
                    (String) clientKeystoreTypeCombo.getSelectedItem());
            Settings.setProperty("davmail.ssl.clientKeystoreFile", clientKeystoreFileField.getText());
            Settings.setProperty("davmail.ssl.clientKeystorePass",
                    String.valueOf(clientKeystorePassField.getPassword()));
            Settings.setProperty("davmail.ssl.pkcs11Library", pkcs11LibraryField.getText());
            Settings.setProperty("davmail.ssl.pkcs11Config", pkcs11ConfigField.getText());

            Settings.setLoggingLevel("rootLogger", (Level) rootLoggingLevelField.getSelectedItem());
            Settings.setLoggingLevel("davmail", (Level) davmailLoggingLevelField.getSelectedItem());
            Settings.setLoggingLevel("org.apache.commons.httpclient",
                    (Level) httpclientLoggingLevelField.getSelectedItem());
            Settings.setLoggingLevel("httpclient.wire", (Level) wireLoggingLevelField.getSelectedItem());
            Settings.setProperty("davmail.logFilePath", logFilePathField.getText());
            Settings.setProperty("davmail.logFileSize", logFileSizeField.getText());

            setVisible(false);
            Settings.save();

            if (osxHideFromDockCheckBox != null) {
                OSXInfoPlist.setOSXHideFromDock(osxHideFromDockCheckBox.isSelected());
            }

            // restart listeners with new config
            DavGateway.restart();
        }
    };
    ok.addActionListener(save);

    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            reload();
            setVisible(false);
        }
    });

    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DesktopBrowser.browse("http://davmail.sourceforge.net");
        }
    });

    buttonPanel.add(ok);
    buttonPanel.add(cancel);
    buttonPanel.add(help);

    add(BorderLayout.SOUTH, buttonPanel);

    pack();
    //setResizable(false);
    // center frame
    setLocation(getToolkit().getScreenSize().width / 2 - getSize().width / 2,
            getToolkit().getScreenSize().height / 2 - getSize().height / 2);
    urlField.requestFocus();
}