Author
getting information from GUI
Kenneth Kelsey
Greenhorn
Joined: Mar 06, 2010
Posts: 4
I would like to be able to retrieve the information typed into a textfield on my gui. What kind of code do I need to take the information typed in and apply it to the rest of my program as a variable.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Mar 06, 2010 17:20:43
0
Web app or Swing or...?
Kenneth Kelsey
Greenhorn
Joined: Mar 06, 2010
Posts: 4
Swing
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Mar 06, 2010 18:11:13
0
Call the getText() method?
Kenneth Kelsey
Greenhorn
Joined: Mar 06, 2010
Posts: 4
How can I get a click event to get information. I am using a go button and three textFields and when I press the go button I want the information in the fields to be available to my program. How would I go about doing that?
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Mar 07, 2010 09:53:06
0
Have you checked out any of the basic Swing tutorials, either at Sun (er... Oracle) or elsewhere?
Kenneth Kelsey
Greenhorn
Joined: Mar 06, 2010
Posts: 4
No, but I will today
Thank You
Vivek Moyal
Ranch Hand
Joined: Nov 02, 2009
Posts: 57
suppose you have one text box name firstField and a button name getValue
now you want the value from the textfiled on click
than you have to implement the actionListener interface so that you will get the button click event
method will look like this
and do this what i did to get the value form the textfield
1
2
and if you want to save it in a variable than do this
make a string variable name saveValue
may be this is your problem's answer
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Mar 07, 2010 11:18:30
0
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.
You can edit your post by using the button.
subject: getting information from GUI