Creating a project in Java, which has only two files: the first file has a GraphicalInterface, which takes the data that the users typed, and is to send the data to the second file called "ProcessData" to process the data, and then send it back to the user to see the graphical interface. In a GUI field, I added a JTextField for the user to enter data in that field, and the code to send to the ProcessData file.

But how do you send the text variable to another file called ProcessData, if that variable is inside a private method? And when the ProcessData class does the processing and sends back the answer, what to type so that the Graphical Interface class receives in the text field, since that text field is inside a private method? Since the method signature cannot be changed because it is an actionPerformed.

I already tried to create an object of the other class to reference the other class, but as the actionPerformed method is private, and cannot change, so I'm not sure how to resolve this.

When creating a Graphical Interface component, an ActionListener is created. The small code is:

private void textFieldActionPerformed(java.awt.event.ActionEvent evt) {
 String text = textFieldName.getText();
}

And when code of the ProcessData class does the processing after receiving the data from GraphicalInterface, how to send back the variable called answer, to the GraphicalInterface, which is within this method of the Graphical Interface:

private void answerFieldActionPerformed (java.awt.event.ActionEvent evt) {
answerfieldname.setText(answer);
}

Please, can anyone help?

0

There are 0 answers