I have 2 screens in Swing, one that calls a method and registers the information in an array, and another screen that should fetch one of this information and display it, the problem is that since the objects are different, I can not get the data of the object that it registers.
Is there any way you can get the address of the object you are registering to use on the search screen and can extract the information from this array or do something like this?
NOTE: It has to be with array, I can not use db or external files.
An example of a Registration screen:
public void formularioCadastro() {
Alunos cadastrarAlunos = new Alunos();
// Cadastra os nomes numa Array
cadastrarAlunos.setNome("Maria", 0); // Nome, posição da Array
cadastrarAlunos.setNome("Lindovania", 1); // Nome, posição da Array
cadastrarAlunos.setNome("Jose", 2); // Nome, posição da Array
cadastrarAlunos.setNome("Josefina", 3); // Nome, posição da Array
cadastrarAlunos.setNome("Maristela", 4); // Nome, posição da Array
}
Search Screen:
public void formularioBusca() {
BuscarAluno buscarNome = new BuscarAluno();
buscarNome.buscar("Jose");
}
What happens is the following, if you run this code, it will give NullPointerException, because the data registered in the "Register Screen" is in the "registerAlunos" object. In order to search the values that were registered there, you would have to use the same object, which in this case is not possible because they are two different screens (files).