I looked through similar questions. But as I do not understand, I address in a separate question. Thank you for your reply.
|
2 answers
Well, you need to dig towards the KeyListener interface. Here is a good example of how it works http://java-lang.at.ua/publ/obrabotka_sobytij/keylistener_obrabotka_sobytij_klaviatury/2-1-0-4
Well, for example:
JPanel panel = new JPanel(); panel.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if(e.getKeyCode() == 10){ //10 - ΠΊΠΎΠ΄ ΠΊΠ»Π°Π²ΠΈΡΠΈ Enter // ΠΊΠ°ΠΊΠΎΠΉ-ΡΠΎ ΠΊΠΎΠ΄, ΠΊΠΎΡΠΎΡΡΠΉ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡΡΡ } } }); |
you need to assign a default button, which just works when you press enter
JButton enter = new JButton(); JRootPane rootPane = SwingUtilities.getRootPane(enter); rootPane.setDefaultButton(enter); |