
How to get the enter key function in multiple jbutton??

hi friend To bind the key with the JButton in Java you will have to use the getInputMap() method of JComponent and put() method of InputMap
for example
button = new JButton("Press Enter ");
button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put
(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
As well as to map action to this button you will have to use
getActionMap() and put() method of ActionMap
for example
button.getActionMap().put("Enter", action);
For detail description go through the link given below
http://roseindia.net/java/example/java/swing/jbutton-key-binding.shtml

can this be used in netbeans??
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.