Example usage for java.awt.event KeyEvent VK_ENTER

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

Introduction

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

Prototype

int VK_ENTER

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

Click Source Link

Document

Constant for the ENTER virtual key.

Usage

From source file:Report_PRCR_New_ETF_Excel_File_Generator.java

private void monthfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthfieldKeyPressed
    if (monthfield.getText().equals("Jan")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Dec");
            int yr = Integer.parseInt(yearfield.getText());

            yearfield.setText("" + (yr - 1));
            monthfield.selectAll();/*from  ww w.j ava2s .co  m*/

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Feb");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Feb")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Jan");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Mar");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Mar")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Feb");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();
        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Apr");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Apr")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Mar");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();
        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("May");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("May")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Apr");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            monthfield.setText("Jun");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Jun")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("May");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Jul");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Jul")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Jun");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Aug");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Aug")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Jul");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Sep");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Sep")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Aug");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Oct");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Oct")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Sep");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Nov");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Nov")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Oct");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Dec");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Dec")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Nov");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Jan");
            int yr = Integer.parseInt(yearfield.getText());

            yearfield.setText("" + (yr + 1));
            monthfield.selectAll();
        }

    }
    if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
        // dayfield.requestFocus();
        // dayfield.selectAll();
    }
    if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
        yearfield.requestFocus();
        yearfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ////// ChaNGE  focus on enter////////////////
        //  dayfield2.requestFocus();
        // dayfield2.selectAll();

    }
}

From source file:GUI.simplePanel.java

public simplePanel() {
    self = this;/*from  w ww. ja  va  2  s.  com*/
    final Microphone mic = new Microphone(FLACFileWriter.FLAC);//Instantiate microphone and have 

    final GSpeechDuplex dup = new GSpeechDuplex("AIzaSyBc-PCGLbT2M_ZBLUPEl9w2OY7jXl90Hbc");//Instantiate the API
    dup.addResponseListener(new GSpeechResponseListener() {// Adds the listener
        public void onResponse(GoogleResponse gr) {
            System.out.println("got response");
            jTextArea1.setText(gr.getResponse() + "\n" + jTextArea1.getText());

            getjLabel1().setText("Awaiting Command");
            if (gr.getResponse().contains("temperature")) {
                try {
                    String reply = util.httpRequest.sendPost("127.0.0.1", 8383, "", "/getServices");
                    JSONObject obj;

                    obj = new JSONObject(reply);
                    JSONArray services = obj.getJSONArray("services");
                    boolean found = false;
                    for (int i = 0; i < services.length(); i++) {
                        if (found) {
                            return;
                        }
                        Object pref = services.getJSONObject(i).get("url");
                        String url = (String) pref;
                        if (url.contains("temp")) {
                            // http://127.0.0.1:8181/sensor/1/temp
                            String serviceHost = (url.split(":")[1].substring(2));
                            int Port = Integer.parseInt((url.split(":")[2]).split("/")[0]);
                            String servicePath = (url.split(":")[2].substring(url.split(":")[2].indexOf("/")));
                            String serviceReply = util.httpRequest.sendPost(serviceHost, Port, "", servicePath);

                            JSONObject temperature;

                            obj = new JSONObject(serviceReply);
                            String temp = obj.getJSONObject("sensor").getString("Temperature");
                            JOptionPane.showMessageDialog(self,
                                    "Temperature is " + temp.substring(0, temp.indexOf(".") + 2) + " Celsius");
                            found = true;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (gr.getResponse().contains("light") || gr.getResponse().startsWith("li")) {
                try {
                    String reply = util.httpRequest.sendPost("127.0.0.1", 8383, "", "/getServices");
                    JSONObject obj;

                    obj = new JSONObject(reply);
                    JSONArray services = obj.getJSONArray("services");
                    boolean found = false;
                    for (int i = 0; i < services.length(); i++) {
                        if (found) {
                            return;
                        }
                        Object pref = services.getJSONObject(i).get("url");
                        String url = (String) pref;
                        if (url.contains("light")) {
                            // http://127.0.0.1:8181/sensor/1/temp
                            String serviceHost = (url.split(":")[1].substring(2));
                            int Port = Integer.parseInt((url.split(":")[2]).split("/")[0]);
                            String servicePath = (url.split(":")[2].substring(url.split(":")[2].indexOf("/")));
                            String serviceReply = util.httpRequest.sendPost(serviceHost, Port, "", servicePath);

                            JSONObject temperature;

                            obj = new JSONObject(serviceReply);
                            String temp = obj.getJSONObject("sensor").getString("Light");
                            JOptionPane.showMessageDialog(self, "Light levels are at " + temp + " of 1023 ");
                            found = true;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

            } else if ((gr.getResponse().contains("turn on") || gr.getResponse().contains("turn off"))
                    && gr.getResponse().contains("number")) {
                int numberIndex = gr.getResponse().indexOf("number ") + "number ".length();
                String number = gr.getResponse().substring(numberIndex).split(" ")[0];
                if (number.equals("for") || number.equals("four")) {
                    number = "4";
                }
                if (number.equals("to") || number.equals("two") || number.equals("cho")) {
                    number = "2";
                }
                if (number.equals("one")) {
                    number = "1";
                }
                if (number.equals("three")) {
                    number = "3";
                }

                try {
                    String reply = util.httpRequest.sendPost("127.0.0.1", 8383, "", "/getServices");
                    JSONObject obj;

                    obj = new JSONObject(reply);
                    JSONArray services = obj.getJSONArray("services");
                    boolean found = false;
                    for (int i = 0; i < services.length(); i++) {
                        if (found) {
                            return;
                        }
                        Object pref = services.getJSONObject(i).get("url");
                        String url = (String) pref;
                        if (url.contains("sensor/" + number)) {
                            // http://127.0.0.1:8181/sensor/1/temp
                            String serviceHost = (url.split(":")[1].substring(2));
                            int Port = Integer.parseInt((url.split(":")[2]).split("/")[0]);
                            String servicePath = (url.split(":")[2].substring(url.split(":")[2].indexOf("/")));
                            String serviceReply = util.httpRequest.sendPost(serviceHost, Port, "", servicePath);

                            JSONObject temperature;

                            obj = new JSONObject(serviceReply);
                            String temp = obj.getJSONObject("sensor").getString("Switch");
                            if (!(temp.equals("0") || temp.equals("1"))) {
                                JOptionPane.showMessageDialog(self,
                                        "Sensor does not provide a switch service man");
                            } else if (gr.getResponse().contains("turn on") && temp.equals("1")) {
                                JOptionPane.showMessageDialog(self,
                                        "Switch is already on at sensor " + number + "!");
                            } else if (gr.getResponse().contains("turn off") && temp.equals("0")) {
                                JOptionPane.showMessageDialog(self,
                                        "Switch is already off at sensor " + number + "!");
                            } else if (gr.getResponse().contains("turn on") && temp.equals("0")) {
                                String serviceReply2 = util.httpRequest.sendPost(serviceHost, Port, "",
                                        "/sensor/" + number + "/switch");
                                JOptionPane.showMessageDialog(self, "Request for switch sent");
                            } else if (gr.getResponse().contains("turn off") && temp.equals("1")) {
                                String serviceReply2 = util.httpRequest.sendPost(serviceHost, Port, "",
                                        "/sensor/" + number + "/switch");
                                JOptionPane.showMessageDialog(self, "Request for switch sent");
                            }

                            found = true;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

            } else if (gr.getResponse().contains("change") && gr.getResponse().contains("number")) {

                int numberIndex = gr.getResponse().indexOf("number ") + "number ".length();
                String number = gr.getResponse().substring(numberIndex).split(" ")[0];
                if (number.equals("for") || number.equals("four")) {
                    number = "4";
                }
                if (number.equals("to") || number.equals("two") || number.equals("cho")) {
                    number = "2";
                }
                if (number.equals("one")) {
                    number = "1";
                }
                if (number.equals("three")) {
                    number = "3";
                }

                try {
                    String reply = util.httpRequest.sendPost("127.0.0.1", 8383, "", "/getServices");
                    JSONObject obj;

                    obj = new JSONObject(reply);
                    JSONArray services = obj.getJSONArray("services");
                    boolean found = false;
                    for (int i = 0; i < services.length(); i++) {
                        if (found) {
                            return;
                        }
                        Object pref = services.getJSONObject(i).get("url");
                        String url = (String) pref;
                        if (url.contains("sensor/" + number)) {
                            // http://127.0.0.1:8181/sensor/1/temp
                            String serviceHost = (url.split(":")[1].substring(2));
                            int Port = Integer.parseInt((url.split(":")[2]).split("/")[0]);
                            String servicePath = (url.split(":")[2].substring(url.split(":")[2].indexOf("/")));
                            String serviceReply = util.httpRequest.sendPost(serviceHost, Port, "", servicePath);

                            JSONObject temperature;

                            obj = new JSONObject(serviceReply);
                            String temp = obj.getJSONObject("sensor").getString("Switch");
                            if (!(temp.equals("0") || temp.equals("1"))) {
                                JOptionPane.showMessageDialog(self,
                                        "Sensor does not provide a switch service man");
                            } else {
                                String serviceReply2 = util.httpRequest.sendPost(serviceHost, Port, "",
                                        "/sensor/" + number + "/switch");
                                JOptionPane.showMessageDialog(self, "Request for switch sent");
                            }

                            found = true;
                        }
                    }
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(self, e.getLocalizedMessage());
                }
            } else if (gr.getResponse().contains("get all")) {

                try {
                    String reply = util.httpRequest.sendPost("127.0.0.1", 8383, "", "/getServices");
                    JSONObject obj;

                    obj = new JSONObject(reply);
                    JSONArray services = obj.getJSONArray("services");
                    boolean found = false;
                    String servicesString = "";
                    for (int i = 0; i < services.length(); i++) {
                        Object pref = services.getJSONObject(i).get("url");
                        String url = (String) pref;
                        servicesString += url + "\n";

                    }
                    JOptionPane.showMessageDialog(self, servicesString);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            } else {
                try {
                    ChatterBotFactory factory = new ChatterBotFactory();
                    ChatterBot bot1 = factory.create(CLEVERBOT);
                    ChatterBotSession bot1session = bot1.createSession();
                    String s = gr.getResponse();
                    String response = bot1session.think(s);
                    JOptionPane.showMessageDialog(self, response);
                } catch (Exception e) {
                }
            }
            System.out.println("Google thinks you said: " + gr.getResponse());
            System.out.println("with "
                    + ((gr.getConfidence() != null) ? (Double.parseDouble(gr.getConfidence()) * 100) : null)
                    + "% confidence.");
            System.out.println("Google also thinks that you might have said:" + gr.getOtherPossibleResponses());
        }
    });
    initComponents();
    jTextField1.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                String input = jTextField1.getText();
                jTextField1.setText("");
                textParser(input);
            }
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void keyReleased(KeyEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
    jButton1.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mousePressed(MouseEvent e) {
            // it record FLAC file.
            File file = new File("CRAudioTest.flac");//The File to record the buffer to. 
            //You can also create your own buffer using the getTargetDataLine() method.
            System.out.println("Start Talking Honey");
            try {
                mic.captureAudioToFile(file);//Begins recording
            } catch (Exception ex) {
                ex.printStackTrace();//Prints an error if something goes wrong.
            }
            //System.out.println("You can stop now");
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                mic.close();//Stops recording
                //Sends 10 second voice recording to Google
                byte[] data = Files.readAllBytes(mic.getAudioFile().toPath());//Saves data into memory.
                dup.recognize(data, (int) mic.getAudioFormat().getSampleRate(), self);
                //mic.getAudioFile().delete();//Deletes Buffer file
                //REPEAT
            } catch (Exception ex) {
                ex.printStackTrace();//Prints an error if something goes wrong.
            }
            System.out.println("You can stop now");

        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    setVisible(true);

}

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

/**
 * Replaces the Ctrl+Enter send command with simple Enter.
 *
 * @param isEnter indicates if the new send command is enter or cmd-enter
 *//*from ww w .  ja  v a 2 s  .  c om*/
public void changeSendCommand(boolean isEnter) {
    ActionMap actionMap = editorPane.getActionMap();
    actionMap.put("send", new SendMessageAction());
    actionMap.put("newLine", new NewLineAction());

    InputMap im = this.editorPane.getInputMap();

    if (isEnter) {
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "send");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_DOWN_MASK), "newLine");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK), "newLine");

        this.setToolTipText("<html>" + GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE")
                + " - Enter <br> " + "Use Ctrl-Enter or Shift-Enter to make a new line" + "</html>");
    } else {
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_DOWN_MASK), "send");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "newLine");

        this.setToolTipText(
                GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE") + " Ctrl-Enter");
    }
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java

/**
 * This method initializes jComboBoxClonedFrom   
 *    //from w w  w  .j  a  va  2 s  .  c  om
 * @return javax.swing.JComboBox   
 */
private JComboBox<String> getJComboBoxClonedFrom() {
    if (jComboBoxClonedFrom == null) {
        jComboBoxClonedFrom = new JComboBox<String>();
        jComboBoxClonedFrom.setRenderer(new ComboToopTip());
        jComboBoxClonedFrom.setEditable(true);
        jComboBoxClonedFrom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                log.debug("jComboBoxClonedFrom.actionPerformed()");
                eventHandler.handleEvent(EventHandler.COMBO_CLONED_FROM);
            }
        });
        refresh(jComboBoxClonedFrom);

        final JTextField editor;
        editor = (JTextField) jComboBoxClonedFrom.getEditor().getEditorComponent();
        editor.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
                char ch = e.getKeyChar();

                if (ch != KeyEvent.VK_ENTER && ch != KeyEvent.VK_BACK_SPACE
                        && (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)))
                    return;
                if (ch == KeyEvent.VK_ENTER) {
                    jComboBoxClonedFrom.hidePopup();
                    return;
                }

                String str = editor.getText();

                if (jComboBoxClonedFrom.getComponentCount() > 0) {
                    jComboBoxClonedFrom.removeAllItems();
                }

                jComboBoxClonedFrom.addItem(str);
                try {
                    String tmpProjectName = null;
                    if (str.length() > 0) {
                        for (int i = 0; i < names.size(); i++) {
                            tmpProjectName = names.get(i);
                            if (tmpProjectName.toLowerCase().startsWith(str.toLowerCase()))
                                jComboBoxClonedFrom.addItem(tmpProjectName);
                        }
                    } else {
                        for (int i = 0; i < names.size(); i++) {
                            jComboBoxClonedFrom.addItem(names.get(i));
                        }
                    }
                } catch (Exception e1) {
                    log.warn(e1.getMessage());
                }

                jComboBoxClonedFrom.hidePopup();
                if (str.length() > 0)
                    jComboBoxClonedFrom.showPopup();
            }
        });

        editor.addFocusListener(new FocusAdapter() {
            public void focusGained(FocusEvent e) {
                if (editor.getText().length() > 0)
                    jComboBoxClonedFrom.showPopup();
            }

            public void focusLost(FocusEvent e) {
                jComboBoxClonedFrom.hidePopup();
            }
        });
    }
    return jComboBoxClonedFrom;
}

From source file:com.NewJFrame.java

private void textFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textFieldKeyTyped
    // TODO add your handling code here:

    if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
        searchTweets();//from  w  w w .  ja v  a  2s.c o  m
    }
}

From source file:org.slage.tests.ImageTest.java

/** Hard-code a pause key click */
public void makePauseHandler() {
    addKeyHandler(new PauseHandler(this), KeyEvent.VK_F10);
    addKeyHandler(new QuitHandler(), KeyEvent.VK_Q, false, true, false);

    // toggle debug mode (bounding shapes, etc)
    addKeyHandler(new ToggleDebugHandler(this), KeyEvent.VK_TAB);

    // cycle toolbar rendering
    addKeyHandler(new CycleRenderHandler(this), KeyEvent.VK_EQUALS);

    addKeyHandler(new FocusConsoleHandler(this), KeyEvent.VK_ENTER);

    // manual scrolling
    addKeyHandler(new ScrollHandler(this, 5, 0), KeyEvent.VK_PAGE_UP);
    addKeyHandler(new ScrollHandler(this, -5, 0), KeyEvent.VK_PAGE_DOWN);

    // toggle scroll lock
    addKeyHandler(new LockViewportHandler(this, tryTheSpecial), java.awt.event.KeyEvent.VK_HOME);
    addKeyHandler(new LockViewportHandler(this), java.awt.event.KeyEvent.VK_END);

    addKeyHandler(new PrintHistory(this), java.awt.event.KeyEvent.VK_F1);

    // open imagetest in the editor
    addKeyHandler(new LaunchEditorHandler(this), java.awt.event.KeyEvent.VK_SCROLL_LOCK);

    // play a sound when space is pressed
    addKeyHandler(//from www . j  av  a  2  s .c  o m
            new PlaySoundHandler(this, Tools.GetFile("org.slage.tests.content", "congratulations-escaped.ogg")),
            java.awt.event.KeyEvent.VK_SPACE);

    // save the game
    addKeyHandler(new SaveWithChooserDialog(this), java.awt.event.KeyEvent.VK_F5);

    // inventory dialog, we hope
    addKeyHandler(new ShowInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_F4);
    addKeyHandler(new CloseInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_ESCAPE);

}

From source file:Report_PRCR_New_ETF_Excel_File_Generator.java

private void yearfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yearfieldKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_UP) {
        yearfield.setText("" + (Integer.parseInt(yearfield.getText()) + 1));
        yearfield.selectAll();/* w  ww  . jav  a  2  s .  c om*/
    }
    if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
        yearfield.setText("" + (Integer.parseInt(yearfield.getText()) - 1));
        yearfield.selectAll();
    }
    if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
        monthfield.requestFocus();
        monthfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ////// ChaNGE  focus on enter////////////////
        //   dayfield2.requestFocus();
        //  dayfield2.selectAll();

    }
}

From source file:com.cmsoftware.keyron.vista.admin.CambiarClave.java

private void correoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_correoKeyTyped
    correo.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        actualizarClave();/* www.  ja  v a  2s  . com*/
    } else {
        labelError.setText("");
    }
}

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

/**
 * Processes the KeyEvent.//from   ww  w  .j  a v  a2s  .  c  om
 * @param ev event
 */
protected void cbxKeyReleased(KeyEvent ev) {
    if (isReadOnlyMode) {
        return;
    }
    if (ev.getKeyCode() == KeyEvent.VK_SHIFT || ev.getKeyCode() == KeyEvent.VK_LEFT
            || ev.getKeyCode() == KeyEvent.VK_RIGHT || ev.getKeyCode() == KeyEvent.VK_CONTROL
            || ev.getKeyCode() == KeyEvent.VK_META) {
        return;
    }

    currentText = textField.getText();
    if (uiFieldFormatter != null) {
        currentText = uiFieldFormatter.formatFromUI(currentText).toString();
    }
    if (currentText.length() == 0 || !hasNewText) {
        if (ev.getKeyCode() == KeyEvent.VK_TAB) {
            if (ev.isShiftDown()) {
                textField.transferFocusBackward();
            } else {
                textField.transferFocus();
            }
            return;
        }

        if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY || ev.getKeyCode() == KeyEvent.VK_DOWN) {
            showPopup(0); // add only
            return;
        }

        if (ev.getKeyCode() != KeyEvent.VK_ENTER) {
            // Add variable to track whether it once had a value and now it does not rods - 02/28/08

            idList.clear();
            list.clear();
            selectedId = null;

            // 02/09/08 - This should not be done here - rods
            // The reason is, that we may have added something only to remove
            // before leaving the control. So we should never send the notification
            // just because we delete the contents. (see wasCleared above)

            /*if (listSelectionListeners != null)
            {
            notifyListenersOfChange(TextFieldWithQuery.this);
            }*/
            //log.debug("setting hasNewText to true"); //$NON-NLS-1$
            hasNewText = true;
        }
    } else {
        hasNewText = true;
        //log.debug("setting hasNewText to true");
    }

    if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY || ev.getKeyCode() == KeyEvent.VK_TAB
            || ev.getKeyCode() == KeyEvent.VK_DOWN) {
        String origText = textField.getText();
        String text = origText;
        if (uiFieldFormatter != null && !uiFieldFormatter.isNumeric()) {
            text = uiFieldFormatter.formatFromUI(text).toString();
        }
        text = StringUtils.replace(text, "'", "\'");
        text = StringUtils.replace(text, "\"", "\\\"");

        // direction of focus change 1: forward 0: none -1: backwards
        int focusChange = (ev.isShiftDown() ? -1 : 1) * (ev.getKeyCode() == KeyEvent.VK_TAB ? 1 : 0);
        doQuery(text, origText, focusChange);
    }
}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes jButton   /*from w w w. j a v  a 2  s . co  m*/
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButtonOK() {
    if (jButtonOK == null) {
        jButtonOK = new JButton();
        jButtonOK.setText("OK");
        jButtonOK.setPreferredSize(new Dimension(100, 28));
        jButtonOK.setEnabled(true);
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                log.debug("actionPerformed() - BtnLogin");

                String userInfo = getJTextFieldUser().getText().trim();
                getJTextFieldUser().setText(userInfo);

                mEventHandler.handle(EventHandler.BTN_LOGIN);

            }
        });
        jButtonOK.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    String userInfo = getJTextFieldUser().getText().trim();
                    getJTextFieldUser().setText(userInfo);
                    mEventHandler.handle(EventHandler.ENTER_KEY_TYTPED);
                }
            }
        });

    }
    return jButtonOK;
}