This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes getting jTextField input 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 jTextField input" Watch "getting jTextField input" New topic
Author

getting jTextField input

Ah Ling
Greenhorn

Joined: Dec 28, 2009
Posts: 12
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

Joined: Dec 28, 2009
Posts: 12
Hey!
So sorry for your time!
I have got it right already!
Thanks!!!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

glitter Air wrote:


Welcome to the Ranch.
Please check your private messages for an important administrative matter


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Piyush Patel
Ranch Hand

Joined: Feb 24, 2009
Posts: 127

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

Joined: Oct 27, 2005
Posts: 19649
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ah Ling
Greenhorn

Joined: Dec 28, 2009
Posts: 12
Ok thanks peeps!
Problem solved already!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting jTextField input
 
Similar Threads
input Form Data lost
Validating Strings in JTextFields
General JSF page navigation questions
JTextField input
Problem when the struts validator rejects user input