0

I want to access JTextField of a class from another class , From the new class i want to setText to the textField.

from class patient_details i want to access the JTextField present in class Admission_screen. This is code which i used in patient_details class to add text in text field present in admission_screen class.

 Admission_screen admit=new Admission_screen();
                 admit.t2.setText("xxx");

t2 is the textfiels present in admission_screen class.

this is not working help me with your suggestions

3
  • Something like this example? Commented Feb 23, 2015 at 4:52
  • 1) "I want to access JTextBox.." There's no such class in the J2SE. 2) "help me with ur suggestions" I suggest you spell words like 'your' properly and check class names before posting. Commented Feb 23, 2015 at 4:58
  • sry .... its Textfield Commented Feb 23, 2015 at 5:01

1 Answer 1

0

Add this method to Admission_screen:

public void setT2Text(String text){
    t2.setText(text);
}

Call it using the admit object you created. Like so: admit.setT2Text("txt");

Sign up to request clarification or add additional context in comments.

1 Comment

your right @Dando18 .......... but I made mistake by creating two objects for one class .... your answer was helpful for me find my mistake ...thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.