Hussain
Hussain

Reputation: 917

Getting values of JTextFields from one class to another class within same package?

I want to use the values of JTextFields from one class in another class within the same package.

How can I do it?

Upvotes: 0

Views: 4854

Answers (1)

raj
raj

Reputation: 3811

Please rephrase your question !! I hope u want to access one class's textfield's value in other class's textfield.

class Class1 
{
      JTextField field1;
      public String getFieldText()
      {
            return field1.getText();
      }
}
class Class2
{
      JTextField field2;
      Class2(Class1 c1)
      {
            field2.setText(c1.getFieldText());
      }
}

Upvotes: 2

Related Questions