Example usage for java.awt.event KeyEvent VK_DOWN

List of usage examples for java.awt.event KeyEvent VK_DOWN

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_DOWN.

Prototype

int VK_DOWN

To view the source code for java.awt.event KeyEvent VK_DOWN.

Click Source Link

Document

Constant for the non-numpad down arrow key.

Usage

From source file:me.solhub.simple.engine.DebugLocationsStructure.java

/**
 * Switches the color of the agent from destination to group or vice versa
 * whenever the space bar is pressed/*  www  .  j  a v  a  2s . c  o  m*/
 */
private void handleColorSwitchingInput() {
    if (_input.isKeyDown(KeyEvent.VK_SPACE) && inputDelayCount > inputDelay) {
        isDestinationColors = !isDestinationColors;
        inputDelayCount = 0;
    }
    if (_input.isKeyDown(KeyEvent.VK_PERIOD)) {
        LIVE_DELAY += 1;
        if (LIVE_DELAY < 0) {
            LIVE_DELAY = 0;
        }
    }
    if (_input.isKeyDown(KeyEvent.VK_COMMA)) {
        LIVE_DELAY -= 1;
        if (LIVE_DELAY < 0) {
            LIVE_DELAY = 0;
        }
    }
    if (_input.isKeyDown(KeyEvent.VK_UP)) {
        _yOffset += 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_DOWN)) {
        _yOffset -= 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_RIGHT)) {
        _xOffset -= 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_LEFT)) {
        _xOffset += 1;
    }
    if (_input.isKeyDown(KeyEvent.VK_ENTER)) {
        while (!_input.isKeyDown(KeyEvent.VK_SHIFT)) {
            //this makes it work, without this line it will not work as desired
            //                System.out.println(_input.isKeyDown( KeyEvent.VK_ENTER ));
            draw();
            handleColorSwitchingInput();
        }
    }
    inputDelayCount++;
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * When CTRL+Z is pressed invokes the <code>ChatWritePanel.undo()</code>
 * method, when CTRL+R is pressed invokes the
 * <code>ChatWritePanel.redo()</code> method.
 *
 * @param e the <tt>KeyEvent</tt> that notified us
 *//*from   w w  w .  j a  v a2 s. c  o m*/
public void keyPressed(KeyEvent e) {
    if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_Z)
    // And not ALT(right ALT gives CTRL + ALT).
            && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) {
        if (undo.canUndo())
            undo();
    } else if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK
            && (e.getKeyCode() == KeyEvent.VK_R)
            // And not ALT(right ALT gives CTRL + ALT).
            && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) {
        if (undo.canRedo())
            redo();
    } else if (e.getKeyCode() == KeyEvent.VK_TAB) {
        if (!(chatPanel.getChatSession() instanceof ConferenceChatSession))
            return;

        e.consume();
        int index = ((JEditorPane) e.getSource()).getCaretPosition();

        StringBuffer message = new StringBuffer(chatPanel.getMessage());

        int position = index - 1;

        while (position > 0 && (message.charAt(position) != ' ')) {
            position--;
        }

        if (position != 0)
            position++;

        String sequence = message.substring(position, index);

        if (sequence.length() <= 0) {
            // Do not look for matching contacts if the matching pattern is
            // 0 chars long, since all contacts will match.
            return;
        }

        Iterator<ChatContact<?>> iter = chatPanel.getChatSession().getParticipants();
        ArrayList<String> contacts = new ArrayList<String>();
        while (iter.hasNext()) {
            ChatContact<?> c = iter.next();
            if (c.getName().length() >= (index - position)
                    && c.getName().substring(0, index - position).equals(sequence)) {
                message.replace(position, index, c.getName().substring(0, index - position));
                contacts.add(c.getName());
            }
        }

        if (contacts.size() > 1) {
            char key = contacts.get(0).charAt(index - position - 1);
            int pos = index - position - 1;
            boolean flag = true;

            while (flag) {
                try {
                    for (String name : contacts) {
                        if (key != name.charAt(pos)) {
                            flag = false;
                        }
                    }

                    if (flag) {
                        pos++;
                        key = contacts.get(0).charAt(pos);
                    }
                } catch (IndexOutOfBoundsException exp) {
                    flag = false;
                }
            }

            message.replace(position, index, contacts.get(0).substring(0, pos));

            Iterator<String> contactIter = contacts.iterator();
            String contactList = "<DIV align='left'><h5>";
            while (contactIter.hasNext()) {
                contactList += contactIter.next() + " ";
            }
            contactList += "</h5></DIV>";

            chatPanel.getChatConversationPanel().appendMessageToEnd(contactList,
                    ChatHtmlUtils.HTML_CONTENT_TYPE);
        } else if (contacts.size() == 1) {
            String limiter = (position == 0) ? ": " : "";
            message.replace(position, index, contacts.get(0) + limiter);
        }

        try {
            ((JEditorPane) e.getSource()).getDocument().remove(0,
                    ((JEditorPane) e.getSource()).getDocument().getLength());
            ((JEditorPane) e.getSource()).getDocument().insertString(0, message.toString(), null);
        } catch (BadLocationException ex) {
            ex.printStackTrace();
        }
    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
        // Only enters editing mode if the write panel is empty in
        // order not to lose the current message contents, if any.
        if (this.chatPanel.getLastSentMessageUID() != null && this.chatPanel.isWriteAreaEmpty()) {
            this.chatPanel.startLastMessageCorrection();
            e.consume();
        }
    } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        if (chatPanel.isMessageCorrectionActive()) {
            Document doc = editorPane.getDocument();
            if (editorPane.getCaretPosition() == doc.getLength()) {
                chatPanel.stopMessageCorrection();
            }
        }
    }
}

From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java

private void initKeyListener() {
    //key listener
    thumbnailList.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_UP)) {
                moveUpButton.doClick();/*from   ww  w .  j a  v a  2 s.c  o  m*/
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_DOWN)) {
                moveDownButton.doClick();
            } else if ((e.getKeyCode() == KeyEvent.VK_DELETE)) {
                removeButton.doClick();
            } else if (drawDeletedItems && (e.isControlDown()) && (e.getKeyCode() == KeyEvent.VK_Z)) {
                undeleteButton.doClick();
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
                rotateButton.doClick();
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_LEFT)) {
                rotateAntiButton.doClick();
            }
        }
    });
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java

@Override
public void keyPressed(KeyEvent ke) {
    Logger.getLogger(getClass().getName()).log(Level.INFO, "Received key event: {0}", ke.toString());
    if (ke.isControlDown()) {
        modeSpinner.setValue(InstanceContentSelectionHandler.Mode.ON_HOVER.toString());
    }//www .j a va 2  s  . c o  m
    if (getDataPoint() != null) {
        Logger.getLogger(getClass().getName()).info("Data point is not null!");
        Point p = null;
        if (ke.getKeyCode() == KeyEvent.VK_RIGHT) {
            p = new Point(getDataPoint());
            p.translate(1, 0);
        } else if (ke.getKeyCode() == KeyEvent.VK_LEFT) {
            p = new Point(getDataPoint());
            p.translate(-1, 0);
        } else if (ke.getKeyCode() == KeyEvent.VK_UP) {
            p = new Point(getDataPoint());
            p.translate(0, 1);
        } else if (ke.getKeyCode() == KeyEvent.VK_DOWN) {
            p = new Point(getDataPoint());
            p.translate(0, -1);
        }
        setDataPoint(p);
        if (!ke.isShiftDown()) {
            //                triggerMSUpdate();
        }
    }
}

From source file:com.jvms.i18neditor.editor.Editor.java

private void setupGlobalKeyEventDispatcher() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(e -> {
        if (e.getID() != KeyEvent.KEY_PRESSED || !e.isAltDown() || (SystemUtils.IS_OS_MAC && !e.isMetaDown())
                || (!SystemUtils.IS_OS_MAC && !e.isShiftDown())) {
            return false;
        }//from   www  .  jav a2 s.  com
        TreePath selected = translationTree.getSelectionPath();
        if (selected == null) {
            return false;
        }
        boolean result = false;
        int row = translationTree.getRowForPath(selected);
        switch (e.getKeyCode()) {
        case KeyEvent.VK_RIGHT:
            if (!translationTree.isExpanded(row)) {
                translationTree.expandRow(row);
            }
            result = true;
            break;
        case KeyEvent.VK_LEFT:
            if (translationTree.isCollapsed(row)) {
                translationTree.setSelectionPath(selected.getParentPath());
            } else {
                translationTree.collapseRow(row);
            }
            result = true;
            break;
        case KeyEvent.VK_UP:
            TreePath prev = translationTree.getPathForRow(Math.max(0, row - 1));
            if (prev != null) {
                translationTree.setSelectionPath(prev);
            }
            result = true;
            break;
        case KeyEvent.VK_DOWN:
            TreePath next = translationTree.getPathForRow(row + 1);
            if (next != null) {
                translationTree.setSelectionPath(next);
            }
            result = true;
            break;
        }
        if (result && !resourceFields.isEmpty()) {
            Component comp = getFocusOwner();
            if (comp != null && (comp instanceof ResourceField || comp.equals(this))) {
                TranslationTreeNode current = translationTree.getSelectionNode();
                if (!current.isLeaf() || current.isRoot()) {
                    requestFocusInWindow();
                } else if (comp.equals(this)) {
                    requestFocusInFirstResourceField();
                }
            }
        }
        return result;
    });
}

From source file:schemagenerator.DBbeheer.java

private void Table_OefeningenKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Table_OefeningenKeyReleased
    if (evt.getKeyCode() == KeyEvent.VK_DOWN || evt.getKeyCode() == KeyEvent.VK_UP) {
        try {//  w w w.  j  a v a 2s  .c o  m
            int row = Table_Oefeningen.getSelectedRow();
            String tableClick = (Table_Oefeningen.getModel().getValueAt(row, 0).toString());
            String sql = "SELECT * FROM oefeningen WHERE spiergroep='" + tableClick + "'";
            pst = con.prepareStatement(sql);
            rs = pst.executeQuery();
            if (rs.next()) {
                String add1 = rs.getString("ID");
                jtfID.setText(add1);
                String add2 = rs.getString("spiergroep");
                jtfSpiergroep.setText(add2);
                String add3 = rs.getString("oefening");
                jtfOefening.setText(add3);
                String add4 = rs.getString("categorie");
                jtfCategorie.setText(add4);
                byte[] imagedata = rs.getBytes("plaatje");
                format = new ImageIcon(imagedata);
                jlPlaatje.setIcon(format);
            }
        } catch (Exception ex) {
            try {
                int row = Table_Oefeningen.getSelectedRow();
                String tableClick = (Table_Oefeningen.getModel().getValueAt(row, 0).toString());
                String sql = "SELECT * FROM oefeningen WHERE spiergroep='" + tableClick + "'";
                pst = con.prepareStatement(sql);
                rs = pst.executeQuery();
                if (rs.next()) {
                    String add1 = rs.getString("ID");
                    jtfID.setText(add1);
                    String add2 = rs.getString("spiergroep");
                    jtfSpiergroep.setText(add2);
                    String add3 = rs.getString("oefening");
                    jtfOefening.setText(add3);
                    String add4 = rs.getString("categorie");
                    jtfCategorie.setText(add4);
                    jlPlaatje.setIcon(null);
                }
            } catch (Exception ex1) {
                JOptionPane.showMessageDialog(null, ex1);
            }
        }
    }
}

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

/**
 * Creates new form JTicketView//  ww  w . j  a va  2  s .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:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @return/*ww  w  .j  a v a  2s.c o m*/
 */
private JPanel createColorCategoriesPanel() {
    JPanel categoryColorsConfigurationPanel = new JPanel(new GridBagLayout());
    categoryColorsConfigurationPanel.setPreferredSize(new Dimension(180, 200));

    GridBagConstraints itemConstraint = new GridBagConstraints();

    JLabel categoryColorsLabel = new ResourceLabel(
            "plotter.configuration_dialog.color_scheme_dialog.category_colors");
    {

        itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        itemConstraint.anchor = GridBagConstraints.WEST;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        itemConstraint.insets = new Insets(0, 5, 5, 5);
        itemConstraint.weightx = 1.0;

        categoryColorsConfigurationPanel.add(categoryColorsLabel, itemConstraint);
    }

    // add button panel
    {
        JPanel buttonPanel = new JPanel(new GridBagLayout());

        // remove scheme button
        {
            removeCategoryColorButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.remove_category_color_button") {

                private static final long serialVersionUID = 1L;

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

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(removeCategoryColorButton, itemConstraint);
        }

        {
            addCategoryButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.add_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    Color oldColor = Color.white;
                    Color newSchemeColor = createColorDialog(oldColor);
                    if (newSchemeColor != null && !newSchemeColor.equals(oldColor)) {
                        addColorAction(newSchemeColor);
                    }
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(addCategoryButton, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.anchor = GridBagConstraints.EAST;
        itemConstraint.insets = new Insets(0, 5, 5, 5);

        categoryColorsConfigurationPanel.add(buttonPanel, itemConstraint);
    }

    {

        JPanel categoryListPanel = new JPanel(new GridBagLayout());

        // add list of categorie colors
        {

            colorList = new JList<Color>(nominalColorListModel);
            categoryColorsLabel.setLabelFor(colorList);
            colorList.setCellRenderer(new ColorListCellRenderer());
            colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            MouseAdapter ma = new MouseAdapter() {

                private void myPopupEvent(MouseEvent e) {
                    int x = e.getX();
                    int y = e.getY();
                    JList<?> list = (JList<?>) e.getSource();
                    list.setSelectedIndex(list.locationToIndex(e.getPoint()));
                    Color selectedColor = (Color) list.getSelectedValue();
                    if (selectedColor == null) {
                        return;
                    }

                    removeMenuItem.setEnabled(nominalColorListModel.getSize() > 2);

                    popupMenu.show(list, x, y);
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }
            };

            colorList.addMouseListener(ma);
            colorList.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyPressed(KeyEvent e) {
                    int key = e.getKeyCode();
                    if (key == KeyEvent.VK_DELETE) {
                        if (nominalColorListModel.getSize() > 2) {
                            removeSelectedColorAction();
                        }
                    }
                    if (key == KeyEvent.VK_F2) {
                        replaceSelectedColorAction();
                    }
                    if (key == KeyEvent.VK_UP && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorUpAction();
                    }
                    if (key == KeyEvent.VK_DOWN && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorDownAction();
                    }
                }
            });

            colorListScrollPane = new JScrollPane(colorList);
            colorListScrollPane.setPreferredSize(new Dimension(170, 200));
            colorListScrollPane.setMaximumSize(new Dimension(170, 200));
            colorListScrollPane.setMinimumSize(new Dimension(170, 180));
            colorListScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            colorListScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 0.0;
            itemConstraint.weighty = 0.5;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;

            categoryListPanel.add(colorListScrollPane, itemConstraint);
        }

        // add up/down button panel
        {

            JPanel upAndDownButtonPanel = new JPanel(new GridBagLayout());

            // add up button
            {
                JButton upButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_up") {

                            private static final long serialVersionUID = 1L;

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

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(upButton, itemConstraint);
            }

            // add down button
            {
                JButton downButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_down") {

                            private static final long serialVersionUID = 1L;

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

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(downButton, itemConstraint);
            }

            // add spacer panel
            {
                JPanel spacer = new JPanel();

                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 1;
                itemConstraint.fill = GridBagConstraints.VERTICAL;

                upAndDownButtonPanel.add(spacer, itemConstraint);

            }

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.weightx = 1;
            itemConstraint.weighty = 1;
            itemConstraint.fill = GridBagConstraints.VERTICAL;

            categoryListPanel.add(upAndDownButtonPanel, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.fill = GridBagConstraints.BOTH;

        categoryColorsConfigurationPanel.add(categoryListPanel, itemConstraint);
    }

    return categoryColorsConfigurationPanel;
}

From source file:savant.view.swing.Savant.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.// w  w w .j  a  v  a  2s . c  o m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    view_buttongroup = new javax.swing.ButtonGroup();
    toolbar_bottom = new javax.swing.JToolBar();
    label_mouseposition_title = new javax.swing.JLabel();
    mousePositionLabel = new javax.swing.JLabel();
    timeCaption = new javax.swing.JLabel();
    label_status = new javax.swing.JLabel();
    s_e_sep = new javax.swing.JToolBar.Separator();
    label_memory = new javax.swing.JLabel();
    panel_browser = new javax.swing.JPanel();
    panel_top = new javax.swing.JPanel();
    panelExtendedMiddle = new javax.swing.JPanel();
    panel_main = new javax.swing.JPanel();
    pluginToolbar = new javax.swing.JPanel();
    menuBar_top = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    loadGenomeItem = new javax.swing.JMenuItem();
    loadFromFileItem = new javax.swing.JMenuItem();
    loadFromURLItem = new javax.swing.JMenuItem();
    loadFromDataSourcePluginItem = new javax.swing.JMenuItem();
    recentTrackMenu = new javax.swing.JMenu();
    javax.swing.JPopupMenu.Separator jSeparator1 = new javax.swing.JPopupMenu.Separator();
    openProjectItem = new javax.swing.JMenuItem();
    recentProjectMenu = new javax.swing.JMenu();
    saveProjectItem = new javax.swing.JMenuItem();
    saveProjectAsItem = new javax.swing.JMenuItem();
    javax.swing.JPopupMenu.Separator jSeparator2 = new javax.swing.JPopupMenu.Separator();
    formatItem = new javax.swing.JMenuItem();
    javax.swing.JPopupMenu.Separator jSeparator3 = new javax.swing.JPopupMenu.Separator();
    exportItem = new javax.swing.JMenuItem();
    jSeparator4 = new javax.swing.JPopupMenu.Separator();
    exitItem = new javax.swing.JMenuItem();
    editMenu = new javax.swing.JMenu();
    undoItem = new javax.swing.JMenuItem();
    redoItem = new javax.swing.JMenuItem();
    javax.swing.JPopupMenu.Separator jSeparator6 = new javax.swing.JPopupMenu.Separator();
    bookmarkItem = new javax.swing.JMenuItem();
    deselectAllItem = new javax.swing.JMenuItem();
    jSeparator7 = new javax.swing.JPopupMenu.Separator();
    preferencesItem = new javax.swing.JMenuItem();
    viewMenu = new javax.swing.JMenu();
    panLeftItem = new javax.swing.JMenuItem();
    panRightItem = new javax.swing.JMenuItem();
    zoomInItem = new javax.swing.JMenuItem();
    zoomOutItem = new javax.swing.JMenuItem();
    toStartItem = new javax.swing.JMenuItem();
    toEndItem = new javax.swing.JMenuItem();
    javax.swing.JSeparator jSeparator8 = new javax.swing.JSeparator();
    crosshairItem = new javax.swing.JCheckBoxMenuItem();
    plumblineItem = new javax.swing.JCheckBoxMenuItem();
    spotlightItem = new javax.swing.JCheckBoxMenuItem();
    windowMenu = new javax.swing.JMenu();
    navigationItem = new javax.swing.JCheckBoxMenuItem();
    genomeItem = new javax.swing.JCheckBoxMenuItem();
    rulerItem = new javax.swing.JCheckBoxMenuItem();
    pluginToolbarItem = new javax.swing.JCheckBoxMenuItem();
    statusBarItem = new javax.swing.JCheckBoxMenuItem();
    speedAndEfficiencyItem = new javax.swing.JCheckBoxMenuItem();
    javax.swing.JSeparator jSeparator9 = new javax.swing.JSeparator();
    bookmarksItem = new javax.swing.JCheckBoxMenuItem();
    pluginsMenu = new javax.swing.JMenu();
    menuitem_pluginmanager = new javax.swing.JMenuItem();
    jSeparator10 = new javax.swing.JPopupMenu.Separator();
    helpMenu = new javax.swing.JMenu();
    userManualItem = new javax.swing.JMenuItem();
    tutorialsItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem checkForUpdatesItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem bugReportItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem featureRequestItem = new javax.swing.JMenuItem();
    javax.swing.JSeparator jSeparator11 = new javax.swing.JSeparator();
    websiteItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setBackground(new java.awt.Color(204, 204, 204));

    toolbar_bottom.setFloatable(false);
    toolbar_bottom.setAlignmentX(1.0F);

    label_mouseposition_title.setText(" Position: ");
    toolbar_bottom.add(label_mouseposition_title);
    toolbar_bottom.add(mousePositionLabel);

    timeCaption.setText("Time: ");
    toolbar_bottom.add(timeCaption);

    label_status.setMaximumSize(new java.awt.Dimension(300, 14));
    label_status.setMinimumSize(new java.awt.Dimension(100, 14));
    label_status.setPreferredSize(new java.awt.Dimension(100, 14));
    toolbar_bottom.add(label_status);
    toolbar_bottom.add(s_e_sep);

    label_memory.setText(" Memory: ");
    toolbar_bottom.add(label_memory);

    panel_top.setMaximumSize(new java.awt.Dimension(1000, 30));
    panel_top.setMinimumSize(new java.awt.Dimension(0, 0));
    panel_top.setPreferredSize(new java.awt.Dimension(0, 30));
    panel_top.setLayout(new java.awt.BorderLayout());

    panelExtendedMiddle.setMinimumSize(new java.awt.Dimension(990, 30));
    panelExtendedMiddle.setPreferredSize(new java.awt.Dimension(990, 30));

    javax.swing.GroupLayout panelExtendedMiddleLayout = new javax.swing.GroupLayout(panelExtendedMiddle);
    panelExtendedMiddle.setLayout(panelExtendedMiddleLayout);
    panelExtendedMiddleLayout.setHorizontalGroup(panelExtendedMiddleLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1045, Short.MAX_VALUE));
    panelExtendedMiddleLayout.setVerticalGroup(panelExtendedMiddleLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 30, Short.MAX_VALUE));

    panel_top.add(panelExtendedMiddle, java.awt.BorderLayout.CENTER);

    panel_main.setBackground(new java.awt.Color(153, 153, 153));
    panel_main.setMaximumSize(new java.awt.Dimension(99999, 99999));
    panel_main.setMinimumSize(new java.awt.Dimension(1, 1));
    panel_main.setPreferredSize(new java.awt.Dimension(99999, 99999));

    javax.swing.GroupLayout panel_mainLayout = new javax.swing.GroupLayout(panel_main);
    panel_main.setLayout(panel_mainLayout);
    panel_mainLayout.setHorizontalGroup(panel_mainLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
    panel_mainLayout.setVerticalGroup(panel_mainLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 532, Short.MAX_VALUE));

    pluginToolbar.setVisible(false);
    pluginToolbar.setPreferredSize(new java.awt.Dimension(856, 24));
    pluginToolbar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));

    javax.swing.GroupLayout panel_browserLayout = new javax.swing.GroupLayout(panel_browser);
    panel_browser.setLayout(panel_browserLayout);
    panel_browserLayout.setHorizontalGroup(
            panel_browserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_top, javax.swing.GroupLayout.DEFAULT_SIZE, 1045, Short.MAX_VALUE)
                    .addComponent(pluginToolbar, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_main, javax.swing.GroupLayout.DEFAULT_SIZE, 1045, Short.MAX_VALUE));
    panel_browserLayout.setVerticalGroup(panel_browserLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_browserLayout.createSequentialGroup().addContainerGap()
                    .addComponent(panel_top, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0)
                    .addComponent(pluginToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0)
                    .addComponent(panel_main, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)));

    fileMenu.setText("File");

    loadGenomeItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G,
            java.awt.event.InputEvent.CTRL_MASK));
    loadGenomeItem.setText("Load Genome...");
    loadGenomeItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadGenomeItemActionPerformed(evt);
        }
    });
    fileMenu.add(loadGenomeItem);

    loadFromFileItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T,
            java.awt.event.InputEvent.CTRL_MASK));
    loadFromFileItem.setText("Load Track from File...");
    loadFromFileItem.setEnabled(false);
    loadFromFileItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadFromFileItemActionPerformed(evt);
        }
    });
    fileMenu.add(loadFromFileItem);

    loadFromURLItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
            java.awt.event.InputEvent.CTRL_MASK));
    loadFromURLItem.setText("Load Track from URL...");
    loadFromURLItem.setEnabled(false);
    loadFromURLItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadFromURLItemActionPerformed(evt);
        }
    });
    fileMenu.add(loadFromURLItem);

    loadFromDataSourcePluginItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E,
            java.awt.event.InputEvent.CTRL_MASK));
    loadFromDataSourcePluginItem.setText("Load Track from Repository...");
    loadFromDataSourcePluginItem.setEnabled(false);
    loadFromDataSourcePluginItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadFromDataSourcePluginItemActionPerformed(evt);
        }
    });
    fileMenu.add(loadFromDataSourcePluginItem);

    recentTrackMenu.setText("Load Recent Track");
    fileMenu.add(recentTrackMenu);
    fileMenu.add(jSeparator1);

    openProjectItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.CTRL_MASK));
    openProjectItem.setText("Open Project...");
    openProjectItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            openProjectItemActionPerformed(evt);
        }
    });
    fileMenu.add(openProjectItem);

    recentProjectMenu.setText("Open Recent Project");
    fileMenu.add(recentProjectMenu);

    saveProjectItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    saveProjectItem.setText("Save Project");
    saveProjectItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveProjectItemActionPerformed(evt);
        }
    });
    fileMenu.add(saveProjectItem);

    saveProjectAsItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    saveProjectAsItem.setText("Save Project As...");
    saveProjectAsItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveProjectAsItemActionPerformed(evt);
        }
    });
    fileMenu.add(saveProjectAsItem);
    fileMenu.add(jSeparator2);

    formatItem.setText("Format File...");
    formatItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            formatItemActionPerformed(evt);
        }
    });
    fileMenu.add(formatItem);
    fileMenu.add(jSeparator3);

    exportItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.CTRL_MASK));
    exportItem.setText("Export Track Images...");
    exportItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuitem_exportActionPerformed(evt);
        }
    });
    fileMenu.add(exportItem);
    fileMenu.add(jSeparator4);

    exitItem.setText("Exit");
    exitItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitItemActionPerformed(evt);
        }
    });
    fileMenu.add(exitItem);

    menuBar_top.add(fileMenu);

    editMenu.setText("Edit");

    undoItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z,
            java.awt.event.InputEvent.CTRL_MASK));
    undoItem.setText("Undo Range Change");
    undoItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            undoItemActionPerformed(evt);
        }
    });
    editMenu.add(undoItem);

    redoItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y,
            java.awt.event.InputEvent.CTRL_MASK));
    redoItem.setText("Redo Range Change");
    redoItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            redoItemActionPerformed(evt);
        }
    });
    editMenu.add(redoItem);
    editMenu.add(jSeparator6);

    bookmarkItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D,
            java.awt.event.InputEvent.CTRL_MASK));
    bookmarkItem.setText("Bookmark");
    bookmarkItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bookmarkItemActionPerformed(evt);
        }
    });
    editMenu.add(bookmarkItem);

    deselectAllItem.setText("Deselect All");
    deselectAllItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuitem_deselectActionPerformed(evt);
        }
    });
    editMenu.add(deselectAllItem);
    editMenu.add(jSeparator7);

    preferencesItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P,
            java.awt.event.InputEvent.CTRL_MASK));
    preferencesItem.setText("Preferences");
    preferencesItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            preferencesItemActionPerformed(evt);
        }
    });
    editMenu.add(preferencesItem);

    menuBar_top.add(editMenu);

    viewMenu.setText("View");

    panLeftItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_LEFT,
            java.awt.event.InputEvent.SHIFT_MASK));
    panLeftItem.setText("Pan Left");
    panLeftItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            panLeftItemActionPerformed(evt);
        }
    });
    viewMenu.add(panLeftItem);

    panRightItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_RIGHT,
            java.awt.event.InputEvent.SHIFT_MASK));
    panRightItem.setText("Pan Right");
    panRightItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            panRightItemActionPerformed(evt);
        }
    });
    viewMenu.add(panRightItem);

    zoomInItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_UP,
            java.awt.event.InputEvent.SHIFT_MASK));
    zoomInItem.setText("Zoom In");
    zoomInItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            zoomInItemActionPerformed(evt);
        }
    });
    viewMenu.add(zoomInItem);

    zoomOutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DOWN,
            java.awt.event.InputEvent.SHIFT_MASK));
    zoomOutItem.setText("Zoom Out");
    zoomOutItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            zoomOutItemActionPerformed(evt);
        }
    });
    viewMenu.add(zoomOutItem);

    toStartItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_HOME, 0));
    toStartItem.setText("Shift to Start");
    toStartItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            toStartItemActionPerformed(evt);
        }
    });
    viewMenu.add(toStartItem);

    toEndItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_END, 0));
    toEndItem.setText("Shift to End");
    toEndItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            toEndItemActionPerformed(evt);
        }
    });
    viewMenu.add(toEndItem);
    viewMenu.add(jSeparator8);

    crosshairItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_J,
            java.awt.event.InputEvent.CTRL_MASK));
    crosshairItem.setText("Crosshair");
    crosshairItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            crosshairItemActionPerformed(evt);
        }
    });
    viewMenu.add(crosshairItem);

    plumblineItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_K,
            java.awt.event.InputEvent.CTRL_MASK));
    plumblineItem.setText("Plumbline");
    plumblineItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            plumblineItemActionPerformed(evt);
        }
    });
    viewMenu.add(plumblineItem);

    spotlightItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L,
            java.awt.event.InputEvent.CTRL_MASK));
    spotlightItem.setText("Spotlight");
    spotlightItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            spotlightItemActionPerformed(evt);
        }
    });
    viewMenu.add(spotlightItem);

    menuBar_top.add(viewMenu);

    windowMenu.setText("Window");
    windowMenu.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            windowMenuStateChanged(evt);
        }
    });

    navigationItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    navigationItem.setText("Navigation");
    navigationItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            navigationItemMousePressed(evt);
        }
    });
    windowMenu.add(navigationItem);

    genomeItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    genomeItem.setText("Genome");
    genomeItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            genomeItemActionPerformed(evt);
        }
    });
    windowMenu.add(genomeItem);

    rulerItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    rulerItem.setText("Ruler");
    rulerItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            rulerItemActionPerformed(evt);
        }
    });
    windowMenu.add(rulerItem);

    pluginToolbarItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    pluginToolbarItem.setSelected(true);
    pluginToolbarItem.setText("Plugin Toolbar");
    pluginToolbarItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            pluginToolbarItemActionPerformed(evt);
        }
    });
    windowMenu.add(pluginToolbarItem);

    statusBarItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    statusBarItem.setSelected(true);
    statusBarItem.setText("Status Bar");
    statusBarItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            statusBarItemActionPerformed(evt);
        }
    });
    windowMenu.add(statusBarItem);

    speedAndEfficiencyItem.setText("Resources");
    speedAndEfficiencyItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            speedAndEfficiencyItemActionPerformed(evt);
        }
    });
    windowMenu.add(speedAndEfficiencyItem);
    windowMenu.add(jSeparator9);

    bookmarksItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    bookmarksItem.setText("Bookmarks");
    bookmarksItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bookmarksItemActionPerformed(evt);
        }
    });
    windowMenu.add(bookmarksItem);

    menuBar_top.add(windowMenu);

    pluginsMenu.setText("Plugins");

    menuitem_pluginmanager.setText("Plugin Manager");
    menuitem_pluginmanager.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuitem_pluginmanagerActionPerformed(evt);
        }
    });
    pluginsMenu.add(menuitem_pluginmanager);
    pluginsMenu.add(jSeparator10);

    menuBar_top.add(pluginsMenu);

    helpMenu.setText("Help");

    userManualItem.setText("Manuals");
    userManualItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            userManualItemActionPerformed(evt);
        }
    });
    helpMenu.add(userManualItem);

    tutorialsItem.setText("Video Tutorials");
    tutorialsItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tutorialsItemActionPerformed(evt);
        }
    });
    helpMenu.add(tutorialsItem);

    checkForUpdatesItem.setText("Check for updates");
    checkForUpdatesItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            checkForUpdatesItemActionPerformed(evt);
        }
    });
    helpMenu.add(checkForUpdatesItem);

    bugReportItem.setText("Report an issue");
    bugReportItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bugReportItemActionPerformed(evt);
        }
    });
    helpMenu.add(bugReportItem);

    featureRequestItem.setText("Request a feature");
    featureRequestItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            featureRequestItemActionPerformed(evt);
        }
    });
    helpMenu.add(featureRequestItem);
    helpMenu.add(jSeparator11);

    websiteItem.setText("Website");
    websiteItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            websiteItemActionPerformed(evt);
        }
    });
    helpMenu.add(websiteItem);

    menuBar_top.add(helpMenu);

    setJMenuBar(menuBar_top);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel_browser, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(toolbar_bottom, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(panel_browser, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(toolbar_bottom, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                            javax.swing.GroupLayout.PREFERRED_SIZE)));

    pack();
}

From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java

private void formKeyPressed(KeyEvent evt) {
    if (lockView) {
        return;/*from   w  w w.  j  av a 2 s. c  o  m*/
    }

    double dAngle = Math.PI / 144;
    double dScale = 129. / 128.;
    if (storingFrames) {
        dAngle = Math.PI / 360;
        dScale = 513. / 512.;
    }
    if ((evt.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        dAngle = Math.PI / 2;
    }
    if ((evt.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {
        dAngle = Math.PI / 6;
    }
    objRotate.getTransform(tempTransform);
    Transform3D rot = new Transform3D();
    switch (evt.getKeyCode()) {
    case KeyEvent.VK_NUMPAD5:
        reset();
        break;
    case KeyEvent.VK_DOWN:
    case KeyEvent.VK_KP_DOWN:
    case KeyEvent.VK_NUMPAD2:
        rot.rotX(dAngle);
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_KP_UP:
    case KeyEvent.VK_NUMPAD8:
        rot.rotX(-dAngle);
        break;
    case KeyEvent.VK_LEFT:
    case KeyEvent.VK_KP_LEFT:
    case KeyEvent.VK_NUMPAD4:
        rot.rotY(-dAngle);
        break;
    case KeyEvent.VK_RIGHT:
    case KeyEvent.VK_KP_RIGHT:
    case KeyEvent.VK_NUMPAD6:
        rot.rotY(dAngle);
        break;
    case KeyEvent.VK_PAGE_UP:
    case KeyEvent.VK_NUMPAD9:
        rot.rotZ(dAngle);
        break;
    case KeyEvent.VK_PAGE_DOWN:
    case KeyEvent.VK_NUMPAD3:
        rot.rotZ(-dAngle);
        break;
    }
    rot.mul(tempTransform);
    objRotate.setTransform(rot);

    switch (evt.getKeyCode()) {
    case KeyEvent.VK_HOME:
    case KeyEvent.VK_NUMPAD7:
        mouseScale *= dScale;
        break;
    case KeyEvent.VK_END:
    case KeyEvent.VK_NUMPAD1:
        mouseScale /= dScale;
        break;
    }
    tempTransform = new Transform3D(new Matrix3d(1., 0., 0., 0., 1., 0., 0., 0., 1.),
            //sceneCenter,
            new Vector3d(0.0, 0.0, 0.0), externScale * mouseScale);
    objScale.setTransform(tempTransform);
    switch (evt.getKeyCode()) {

    case CAMERA_UP_KEY:
        cameraUpKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_DOWN_KEY:
        cameraDownKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_LEFT_KEY:
        cameraLeftKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_RIGHT_KEY:
        cameraRightKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_FORWARD_KEY:
        cameraForwardKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_BACKWARD_KEY:
        cameraBackwardKeyPressed = true;
        processCameraKeys(evt);
        break;

    // TODO milimetr: delete the code below after testing
    case '8':
        pickObject.setPickModuleMode(1);
        break;
    case '9':
        pickObject.setPickModuleMode(2);
        break;
    case '0':
        pickObject.setPickModuleMode(3);
        break;

    default:
        break;
    }
}