How to get data from Jframe

Asked

Viewed 52 times

0

Hello, lately I have the following question: how to take a data that was generated in a jframe and send to another class. The idea is to use the jframe just to fill and return me the values that was inserted there to another class, which in the case would be the main, has how to do this?

1 answer

1

Well, jframe is nothing more than a class, so you could for example in jframe that will be given the return of the information create variables that will save this information so that when it closeVoce can obtelos by get’s for example... Example> Let’s pretend that I have a jframe already open and I will open another right now that will be the registration of a client... then I say

Cadastro_Cliente cad = new Cadastro_Cliente();
cad.setvisible(true);

Soon my house is visible, and I’ll fill everything in it. at the end I saved all the information in variables and also created the getteres for them.. as for example:

public String getNome(){
return this.nome;
}

Right after this form "Cad" closed with event . Dispose() I can access the values that contained in the variables.. Example:

if (cad.getNome()!=null){
system.out.println(cad.getNome());
}

Browser other questions tagged

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