Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes getting information from GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getting information from GUI" Watch "getting information from GUI" New topic
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

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

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

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

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting information from GUI
 
Similar Threads
i was made some mistake in gridbaglayout so pls help me
Validating the Data File
JTextField problem
Display information from a database in a custom made GUI
Local Inner Class