I want to call the data that is entered in a jtextfield from a main class, can it?

0

In my program I would like to call a jframe called "frame1" from a main class in that jframe I have 2 jtextfield, I want to enter values in those jtextfield and then use these values in the main class but it tells me that jtextfield are in private and I can not access them what can I do ???

    
asked by Arley Steven Lache Rueda 28.02.2018 в 17:34
source

1 answer

0

Create inside the class where you have the attribute jTextField2 a getter method that returns it and in this way you can access it from another class.

public JTextField getJTextField2() {
    return jTextField2;
}

Then you can do something like this:

ahorro[i] = Integer.parseInt(frame1.getJTextField2().getText());
    
answered by 28.02.2018 в 21:36