How to transfer data from a graphical interface to another Java file and receive it later after data processing

Asked

Viewed 62 times

0

Creating a Java project, which has only two files: the first has a InterfaceGrafica, that takes the data that users will enter, being responsible for sending the data to the second file called ProcessarDados, where they will be processed, and then send back to the user to view the graphical interface. In a GUI field, I added a Jtextfield for the user to enter data in this field and the code to be sent to the Processed file.

But how to send the text variable to another file called Processed, if that variable is within a private method? And when the Processed class does the processing and returns the response, what do you type for the Graphical Interface class to receive in the text field, since this text field is inside a private method? Since the signature of the method cannot be changed because it is an actionPerformed.

I have tried to create an object from the other class to reference another class, but since the actionPerformed method is private and cannot be changed, I am not sure how to solve this.

When creating a GUI component, an Actionlistener is created. The small code is:

private void nomeCampoTextoActionPerformed(java.awt.event.ActionEvent evt) {
 String texto = nomeCampoTexto.getText();
}

And when the code of the Processed class does the processing after receiving the data from Interfacegrafica, how to send back the variable called response, to Interfacegrafica, which is within this method of Interfacegrafica:

private void campoRespostaActionPerformed (java.awt.event.ActionEvent evt) {
campoResposta.setText(resposta);
}

Please, can someone help?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.