Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
actionevent
- Page 1
ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by DoubleGee
… buttons work. Here is my actionPerformed method: public void actionPerformed(
ActionEvent
evt) { if(evt.getSource().equals(printButton)) // This is the first…
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by DoubleGee
…. Any suggestions what the problem might be? public void actionPerformed(
ActionEvent
evt) { if(evt.getSource().equals(printButton)) { System.out.println(inResult…
GUI Actions With Objects, ActionEvent ActionListener
Programming
Software Development
14 Years Ago
by kezkez
… like ... class Action2 implements ActionListener { public void actionPerformed (
ActionEvent
e) { String record1 = field2.getText(); String record2 =…,400)); } class Action implements ActionListener { public void actionPerformed (
ActionEvent
e) { String newDatabaseName = field1.getText(); StudentDB db =…
Faking An ActionEvent
Programming
Software Development
14 Years Ago
by ajst
… currently have a method that is called on a
ActionEvent
of being clicked. Now I want to call that … want to call. [CODE] private void gameEndTurnBtnActionPerformed(java.awt.event.
ActionEvent
evt) { if(theGame.WhosTurn() == 1) { theGame.SetWhosTurn(2);…
If statement non functional in button ActionEvent
Programming
Software Development
10 Years Ago
by shayan_doust
… java.awt.event.ActionListener; import java.awt.event.
ActionEvent
; import javax.swing.*; import java.awt.event.*; public…(true); button.addActionListener(new ActionListener() { public void actionPerformed(
ActionEvent
e){ if(parseduserguess > numberToGuess){ result.setText("…
Re: If statement non functional in button ActionEvent
Programming
Software Development
10 Years Ago
by Heanre
…awt.event.ActionListener; import java.awt.event.
ActionEvent
; import javax.swing.*; import java.awt.…); button.addActionListener(new ActionListener() { public void actionPerformed(
ActionEvent
e) { int numberToGuess = rand.nextInt(100); int…
Re: actionListener & actionEvent in diffirent classes
Programming
Software Development
14 Years Ago
by Dean_Grobler
… normaly you do that and then you have a method
actionEvent
/actionPerformed method in the same class that then says what… is clicked. What I want to do, is have this
actionEvent
/actionPerformed method, in ANOTHER class. Make sense?
Re: Faking An ActionEvent
Programming
Software Development
14 Years Ago
by JamesCherrill
Since your method's code doesn't actually use the
ActionEvent
parameter, you could just call gameEndTurnBtnActionPerformed(null); from anywhere in your class (or anywhere else if you make it public).
Re: Faking An ActionEvent
Programming
Software Development
14 Years Ago
by ajst
… needs to know [CODE] private void gameEndTurnBtnActionPerformed(java.awt.event.
ActionEvent
evt) { if(theGame.WhosTurn() == 1) { theGame.SetWhosTurn(2); theGame.ResetMoved…
The e.getSource() method from ActionEvent e in a listener
Programming
Software Development
15 Years Ago
by mastr924
In the listener for a button in the actionPerformed(
ActionEvent
e) part, if you call e.getSource it returns a type object. So how can I turn that object that it returns into the original button?
actionListener & actionEvent in diffirent classes
Programming
Software Development
14 Years Ago
by Dean_Grobler
Hi there, I just wanted to find out if one can have a actionListener() in one .class file and then have the
actionEvent
() in another .class file? If not, how would I go about to get the same effect? Thanks!
Re: actionListener & actionEvent in diffirent classes
Programming
Software Development
14 Years Ago
by JamesCherrill
This question doesn't quite make sense - the
actionEvent
is created by Swing normally. Can you please explain exactly what you want to achieve?
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by JamesCherrill
Your second and third if tests should look like the first one `if(evt.getSource().equals(theAppropriateJBUtton)` then inside those if blocks you can test `bgColor` or `disabledText` as appropriate
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by JamesCherrill
You have lost the original if tests on bgColor and textEditable. You need them both... if (this is the disable button) { if (disableText) { disableText = false; inResult.setEditable(true); else { disableText = true; inResult.setEditable(false) } }
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by DoubleGee
Thank you very much! I really appreciate your help! :)
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by DoubleGee
One last question: Is there a way to print the contents of a JTextField by pressing enter?
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by JamesCherrill
Here's a discussion that may help... http://www.coderanch.com/t/342428/GUI/java/write-event-Enter-key
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by DoubleGee
Thanks for the link **JamesCherrill** *"For example,i enter text in a textfield and hit "enter",i want to send this to a textArea"* I don't think you understood me correctly. The person who started the thread is saying that when he presses the Enter key he wants the text to move from the inPut to outPut JTextField. I have only …
Re: ActionEvent for multiple JButtons
Programming
Software Development
13 Years Ago
by 117
I think I know what you mean. What you need to take a look at is called `KeyListener`. This is provided by oracle's tutorials: [KeyListeners](http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/event/KeyListener.html) Make sure to read through and you will probably understand how KeyListeners work. Here is a Code-Snippet to get you started:…
ActionEvent issue
Programming
Software Development
15 Years Ago
by Gary888
Hello from Ireland, In NetBeans I created a class that extends JFrame called “SearchCustomerPage”. The class has a JButton called “Search” that has an ActionListener associated with it (so when I click “Search” a method is called). I have another JFrame page (“NewBookingPage”) that creates bookings. To create a booking the user enters various…
Re: ActionEvent issue
Programming
Software Development
15 Years Ago
by musthafa.aj
as per my knowledge its not feasible... class 'a' getting only after all the things executed in class 'b'.. while running class 'b' class 'a' can't notify anything...
Re: ActionEvent issue
Programming
Software Development
15 Years Ago
by JamesCherrill
Easy way is to have a public method in the booking form class, pass the current instance of that class to the constructor of the search form class, then simply call the method on the instance when required. This creates a hard-coded dependency between the search and booking classes which may be a problem if you want to use the search in other …
Re: GUI Actions With Objects, ActionEvent ActionListener
Programming
Software Development
14 Years Ago
by JamesCherrill
The action listeners are both inner classes of your main class, so if you move the declaration of [I]StudentDB db[/I] out to the main class class you can access it from both listeners.
Re: GUI Actions With Objects, ActionEvent ActionListener
Programming
Software Development
14 Years Ago
by kezkez
i would like the action of creating a new [I]StudentDB[/I] when entering it's name into the first field, not quite following how i can do that in main, could you provide an example? here is the main class i'm working with... [code] import javax.swing.JFrame; import javax.swing.*; import java.awt.*; public class MyDbGUI { public static void …
Re: GUI Actions With Objects, ActionEvent ActionListener
Programming
Software Development
14 Years Ago
by kezkez
nevermind, i understand this part now, thanks!
Re: Faking An ActionEvent
Programming
Software Development
14 Years Ago
by jon.kiparsky
Do you mean something like the fireActionPerformed() method found in AbstractButton?
Re: Faking An ActionEvent
Programming
Software Development
14 Years Ago
by Ezzaral
There is also a doClick() method on buttons.
Re: Faking An ActionEvent
Programming
Software Development
14 Years Ago
by ajst
Cheers JamesCherrill, thats exactly what i wanted, Thought it would throw exception if used null.
Re: Faking An ActionEvent
Programming
Software Development
14 Years Ago
by JamesCherrill
[QUOTE=ajst;1482134]Cheers JamesCherrill, thats exactly what i wanted, Thought it would throw exception if used null.[/QUOTE] It would throw an NPE exception IF you tried to use that parameter, but you don't. Passing null as an Object param is always valid syntax (unless it leaves you with an ambiguous method ref, which won't happen in this case…
Re: If statement non functional in button ActionEvent
Programming
Software Development
10 Years Ago
by shayan_doust
I apologise for the code being too messy. I spent hours trying to resolve the problem but still failed. This is my first app.
1
2
3
17
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC