0
My idea is to open this window passed as parameter without it losing any attribute, for example, I have the class :
public class Teste {
JFrame janela = new JFrame;
public ControllerJPreTransacao(JFrame janela) {
this.janela = janela;
initEvents();
}
private void initEvents(){
janela.setVisible(true); //NullPointerException
}
}
As they might notice the commentary, in certain part of the class the eclipse accuses NullPointerException on the line I leave the janela visible, which makes no sense, since I already instated it at the beginning of the class. Due to this error the eclipse does not even open the frame. What am I missing?
Take a good look at what you are doing. If you receive a Frame as parameter, why new Frame? Remove it
JFrame janela = new JFrame;, since you are getting a window in the builder.– user28595
I’ve tried to do without that
new, but the IDE continues to accuse the same error, on the same line ...– Daniel Santos
How are you starting this class? Jframe is being passed as null.
– user28595
Good ! This is exactly what was missing ! There was no instantiation of the window passed as parameter !
– Daniel Santos