This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting jTextField input

 
Ah Ling
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day to all!

I met one problem while doing my project.
I have two classes.
One class is like a form which will take in input from the user using jTextField.
Another class is like a summary which will display what the user had entered in the form.
Can I display the input entered in the form at my latter class in jLabel or jTextField?

I tried the methods that I have found online but it does not help.
Any kind soul can provide me a simple example? I'll try to figure it myself.
 
Ah Ling
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!
So sorry for your time!
I have got it right already!
Thanks!!!
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
glitter Air wrote:


Welcome to the Ranch.
Please check your private messages for an important administrative matter
 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create static mathod that returns jTextField value . (make JTextField Object Static as well) .
then call,

String val=ClassName.getJTextFieldVal();

which gives you uour jTextField value in Another class.
 
Rob Spoor
Sheriff
Pie
Posts: 20496
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, don't. Static component fields are just about never a good idea. Instead, make it an instance field, make the method non-static and just use a reference to an existing object to call the method on.
 
Ah Ling
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks peeps!
Problem solved already!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic