Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting information from GUI

 
Kenneth Kelsey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web app or Swing or...?
 
Kenneth Kelsey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call the getText() method?
 
Kenneth Kelsey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out any of the basic Swing tutorials, either at Sun (er... Oracle) or elsewhere?
 
Kenneth Kelsey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, but I will today

Thank You
 
Vivek Moyal
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic