I have a login form (jFrame1) which has a jTextField1 to take input (employee id) from the user.

I want that the value of employee id given by user in jTextfield1 should be transfered to jLabel1 in user main frame (jFrame2) when the user press login button present in the login form (jFrame1)

Please Help !
Deadline is near to submitt my project.. and this is a big headache for me .

Thanx in Advance

email : priyanjan.kumar19@gmail.com

Recommended Answers

All 6 Replies

In the MainFrame class call a method in the LoginForm class that returns the contents of jTextField1
and use thst to set the text of jLabel1.

Or have the button listener in the LoginFormm class get the value from the text field and call a method in the MainFrame class and pass it the value that it can set the jLabel text to.

Basically you are trying to submit the employeeId from the frame1 which is being implemented in let's say class Employee to a frame2 which is let 's say being implemented in the class User

So, what you should do is when you call the class User, you parse the text you got from the TextField as parameter.
Example below:

     public class Employee
     //some codes
     //When calling the class User
         new User(empId);
     //empId: text received from TextField(employeeId)
     //some codes   

     public class User
     //some codes
     //when defining the constructor
     //parse the employeeID from Employee
         String empId;
         public User(String empId)
         {
             this.empId=empId;
         }
     //some codes

Hope this helps dude :)

don't use two or more JFrames, use CardLayout instead, if you need popup window for input of value use JOptionPane

Than you sooo much Mr Mehfooz ..
Solution given by you is perfect and exactly to the point what was needed by me.
Thanx...

You are Welcome! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.