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




Have Programming Question? Ask it here!
 
 
 


java
Jbutton
2 Answer(s)      a year and 8 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 use enter function in jbutton?plzz help
Jbutton
Jbutton  How to get the enter key function in multiple jbutton
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
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
how to reduce width of jbutton ?
how to reduce width of jbutton ?  how to reduce width of jbutton ? thanks in advancwe
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 - Swing AWT
java    while inserting in data in text field and click the jButton and save the data in sql 2005
regarding JTable - JDBC
regarding JTable  how to populate a JTable with mysql data after clicking JButton please explain with the example
java swings - Java Beginners
java swings  Hi, I need simple code for JButton JOptionPane.Please send the code. Thanks, Valarmathi
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
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
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
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 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
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 code - Java Beginners
Java code  how to make a program in java(Jbutton) if there is a combination numbers inorder to exit the program else the background color of the frame will turns red
source code - Swing AWT
source code  source code for a program to shutdown, restart, log off the pc after clicking jbutton on jpanel or a jframe by user. thanks in advance
Scroll in JPanel
JPanel(); JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button 2
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
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
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
java
java  find the errors in the following code fragment and explain how to correct them button1=new JButton("OK"); JTextField text1=JTextField(10...); c.add(text1);   JButton button1=new JButton("OK"); JTextField text1
JTable - Cell selection - Swing AWT
); getContentPane().add(spane); JButton button = new JButton("Click Button...); table.requestFocus(); } }); final JButton jbutton = new JButton("De...()) { table.editingStopped(new ChangeEvent(jbutton
SplitButton of dropdownbutton invisible when mouse clicking - Swing AWT
javax.swing.plaf.basic.BasicArrowButton; public class SplitButton1 extends JButton { private JButton mainButton, dropDownButton; private JMenu dropDownMenu...(String text) { this(new JButton(text), SwingConstants.SOUTH
Java Calculator program - Java Beginners
; String s1,s2,s3,s4,s5; Frame f; JButton...; Calculator() { f=new Frame("Calculator"); p=new Panel(); b1=new JButton("0"); b1.addActionListener(this); b2=new JButton("1"); b2.addActionListener
Jtabbedpane - Java Beginners
with the user by this button. So...;Java Example for adding abstarct JButton...(tab, BorderLayout.CENTER); JButton   Java Example for adding abstarct JButton in JTabbedPane and interacting with user using this JButton.Code
java buttons - Swing AWT
= new JFrame("JFrame"); final JPanel p1 = new JPanel(); JButton a = new JButton("A"); JButton b = new JButton("B"); p1.add(a); p1.add(b...()); JButton c = new JButton("C"); p2.add(c); f.setSize(150, 100
How to close a frame on action event of a button from a different class ?
? I have a designed a control-frame on 1 class which has jbutton components, I... was opened when I had press first jbutton from control-frame) when I press second jbutton from control-frame
Non Editable Text File in java - Java Beginners
Non Editable Text File in java  Hello Sir ,I want to Show NonEditable TextFile on JButton Click which Contains User Manual of Project ,How I can Do It. plz Help Me
button with rounded corner in java
button with rounded corner in java  Hi, I want to create a JButton with rounded corners in swings. I went through many programs but did not got the solutions. Thanks and regards, Vivek Birdi
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
Java Swing Scientific Calculator
= 0, z = 0; char ch; JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, zero, clr...)); boolean t = true; mr = new JButton("MR"); buttonpanel.add(mr); mr.addActionListener(this); mc = new JButton("MC"); buttonpanel.add(mc
program a combination locker
and limitations of 1 to 9 by 1 The Reset JButton will reset all the JSpinners to the default value of 5. The Open JButton will test to see if the combination set
Gui Interface - Java Beginners
Gui Interface  hi I have two seperate interfaces in the same projects . my question is how can I access this interface using a jbutton (i.e jbutton = next where next points to another interface addCourse.java) What would
GUI problem - Java Beginners
; Handle the actionPerformed event for JButton and try doing something like...; Handle the actionPerformed event for JButton and try doing something like
 

 

 

DMCA.com