Results 1 to 5 of 5
Thread: take value other form
- 11-17-2008, 08:48 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 41
- Rep Power
- 0
take value other form
I have a problem like this:
I have a form LogIn with 2 textfileds Username and Password
when i enter a correct username and password , application will hide a LogIn form and show form 2
What i want to ask is how to take a Username value that i just entered in form LogIn and and set to the TextField in form 2 like " Welcome (username value from Log In form)" ?
i tried:
Form LogIn:
public String user = UserName.getText();
Form 2:
LogIn log =new LogIn();
textfield.setText(log.user);
and that not work ! the textfield is blank...
Help me !!
-
by "Form" do you mean JFrame? Myself, I'd have a public method in the first class, the one responsible for handling your login GUI, something like so:
Then in the second class, when I wanted this data, I'd call this method on an instance of the first class (the instance that was displayed!).Java Code:public String getUserName() { // assuming that this class has a private JTextField variable // named userNameTextField return userNameTextField.getText(); }
- 11-18-2008, 04:32 AM #3
Member
- Join Date
- Aug 2008
- Posts
- 41
- Rep Power
- 0
oh thanks, i 'll try that, thanks for reply!
- 11-18-2008, 09:22 AM #4
Member
- Join Date
- Aug 2008
- Posts
- 41
- Rep Power
- 0
I already tried that, but did'nt work
LogIn Form:
private JTextField userName;
public String getUsername()
{
return userName.getText();
}
SecondForm:
LogIn log = new LogIn();
JTextField.setText(log.getUsername());
the text in the JtextField is blank T_T
- 11-18-2008, 09:37 AM #5
Well, if you've just instantiated the Login class, the userName JTextField is blank, isn't it? And that's where you're getting the text that you're setting to....
Hey wait. setText isn't a static method, you can't invoke it on the class.
Hop across to the Sun site and find the Swing tutorial. You need it badly.
db
Similar Threads
-
New to this form
By talasilasumanth in forum IntroductionsReplies: 5Last Post: 10-30-2008, 12:34 PM -
enctype=multipart/form-data with form data in struts
By vk_satheesh in forum New To JavaReplies: 0Last Post: 09-19-2008, 12:48 PM -
how to read a form with JFS
By crispy in forum JavaServer Faces (JSF)Replies: 2Last Post: 05-01-2008, 03:07 PM -
1 form 2 servlets
By sandor in forum Java ServletReplies: 2Last Post: 01-22-2008, 10:47 AM -
Form Help Pls
By CoOlbOyCoOl in forum NetBeansReplies: 4Last Post: 05-27-2007, 08:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks