Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


java
Jbutton
2 Answer(s)      a year and 10 months ago
Posted in : Java Beginners


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


Advertisement
View Answers

January 10, 2013 at 7:28 PM


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



January 12, 2013 at 12:02 PM


can this be used in netbeans??



Related Tutorials/Questions & Answers:
Jbutton
Jbutton  How to get the enter key function in multiple jbutton
jbutton
jbutton  How to use enter function in jbutton?plzz help
Advertisements
How to put an image on a JButton?
How to put an image on a JButton?  How to put an image on a JButton
how to reduce width of jbutton ?
how to reduce width of jbutton ?  how to reduce width of jbutton ? thanks in advancwe
Jbutton[] background & foregroundcolor change
Jbutton[] background & foregroundcolor change  how to change the color of the selected JButton in java swing. I am create JButton in an array JButton button[]=new JButton[100]; if i select button[5] then the Jbutton
3D JButton in java?
3D JButton in java?  how we can create 3D button in java. thanks
Jbutton in JTable cells
Jbutton in JTable cells  I am a Java Beginner... I want a code in which I display data in Jtable from database and correspondingly a JButton for each cell and when i click on that button a new window should open
jbutton - Java Beginners
jbutton  Hi, I have jlist and jbutton options.If i select... are displyed in the jlist using jbutton(refresh button). I want to know how to refresh... listModel; JList list ; public JListExample() { super(Select); JButton
How to put points on a JButton
How to put points on a JButton  I wanted to ask....what am i supposed to do if i wanna set points on my JButton so as to be able to draw arcs or curves.... supposedly my button represents a tile with 2 openings and the opening
Java Swing : JButton Example
Java Swing : JButton Example In this section we will discuss how to create button by using JButton in swing framework. JButton : JButton Class extends... JButton labeling with some String .Some events are handled with the button
Open TextFile on JButton Click - Java Beginners
Open TextFile on JButton Click  Hello Sir I Want to open TextFile on JButton Click. plz Help Me  Hi Friend, Do you want to simply open the text file or you want to open the file using JFileChooser,read that file
how to open a file with a jbutton? - Java Beginners
how to open a file with a jbutton?  Hello Is it possible that by clicking on a button it can open java html file or doc exists on the pc? I searched and I found that it is possible to open a web page so I tried to open
How to Open Text or Word File on JButton Click in Java - Java Beginners
How to Open Text or Word File on JButton Click in Java  How to Open Text or Word File on JButton Click in Java
Create and Show Wordpad File on JButton Click - Java Beginners
Create and Show Wordpad File on JButton Click  Hello Sir I want to create wordpad or word document on JButton Click Event.which contains data which...; import org.apache.poi.poifs.filesystem.*; class Form extends JFrame{ JButton
Open Text or Word Document on JButton Click in Java - Java Beginners
Open Text or Word Document on JButton Click in Java  How to open Word document or Text File on JButton Click in java  Hi Friend, Try... JFrame{ JButton ADD; JPanel panel,pan; JLabel label1,label2,label3,label4
Adding a Rollover and Pressed Icon to a JButton Component in Java
Adding a Rollover and Pressed Icon to a JButton Component in Java... about adding event i.e. the rollover and click icon to a JButton component of swing...: button.setRolloverIcon(Icon icon_name): This is the method of the JButton class which is used
Changing the Label of a JButton Component in Java
Changing the Label of a JButton Component in Java... to change the label of a button in java swing. JButton is the component of javax.swing....;new JButton("Click Me");   button.addActionListener
Java JButton Key Binding Example
Java JButton Key Binding Example In this section we will discuss about how... example which will demonstrate you about how to bind Enter key on JButton... JPanel for adding the JButton and then added these panel to a Container
Sum of a Number using Swing
. JTextField, JButton is a component of GUI. Brief description of the Component...;JTextField(20); 3. JButton with a String as a label, and then drop...; JButton button = new JButton("Calculate"
Code how to? - Java Beginners
Code how to?  how to access a separate form using a JButton ? Also how to let another Jbutton access an excel spreadsheet for viewing? Thanks
java swings - Java Beginners
java swings  Hi, I need simple code for JButton JOptionPane.Please send the code. Thanks, Valarmathi
regarding JTable - JDBC
regarding JTable  how to populate a JTable with mysql data after clicking JButton please explain with the example
java - Swing AWT
java    while inserting in data in text field and click the jButton and save the data in sql 2005
ArrayList - Java Beginners
{ JTextField txtAdd=new JTextField(35); JButton btnAdd=new JButton("Add"); JButton btnSize=new JButton("Size"); JButton btnFirst=new JButton("First"); JButton btnLast=new JButton("Last"); JButton btnFind=new JButton("Find
images - Java Beginners
); content.setLayout(new FlowLayout()); JButton button1 = new JButton.../vinod/amarexamples/javalogo.gif"); JButton button2 = new JButton(cup); content.add(button2); JButton button3 = new JButton("Java", cup
file reader
); JButton b1 = new JButton("file1"); panel.add(b1); JButton b2 = new JButton("file2"); panel.add(b2); JButton b3 = new JButton("Quit..."); JButton iconButton1 = new JButton(icon11
Java enter Key problem - Java Beginners
Java enter Key problem  How we can use Enter Key to Click a Button(JButton) in Java?  hi, i guess u mean u want to make a button...().setDefaultButton(JButton defaultButton) thats
java compilation error - Java Beginners
); } } class ActionButtonsPanel extends JPanel { ActionButtonsPanel () { JButton addBut = new JButton("Add"); JButton multBut = new JButton("mult"); add(addBut); add...{ ActionButtonsPanel () { JButton addBut = new JButton("Add"); JButton multBut = new
java compilation - Java Beginners
extends JPanel { ActionButtonsPanel () { JButton addBut = new JButton("Add"); JButton multBut = new JButton("mult"); add(addBut); add(multBut... { ActionButtonsPanel () { JButton addBut = new JButton("Add"); JButton
scrollbar in JPanel
f = new Frame ("Demo");JPanel p = new JPanel();JButton b1 = new JButton("Button 1");JButton b2 = new JButton("Button 2"...) { Frame f = new Frame ("Demo"); JPanel p = new JPanel(); JButton b1 = new JButton
Adding JTable into existing Jframe.
"); JButton add=new JButton("ADD NEW"); JButton edit=new JButton("EDIT"); JButton delete=new JButton("DELETE"); JButton save=new JButton("SAVE"); JButton cancel=new JButton("CANCEL"); JButton close=new JButton("CLOSE"); JButton print
Advertisements
 

 

 

DMCA.com