java - Swing: Visual interface connect to second frame -
i have 2 frames. want first frame open second. tried this, leads exception.
class aboutaction implements actionlistener { public void actionperformed(actionevent e) { frame.dispose(); aboutinfo = new aboutinfo(); about.frame.setvisible(true); } } about.addactionlistener(new aboutaction());
this full program: https://github.com/zhelyazkov97/fuel-calculator.git.
you're basic problem nullpointerexception
create misunderstanding of how swing works , bad design.
basically, define class as...
public class aboutinfo extends jframe { private jpanel contentpane; javax.swing.jframe frame;
now, here confusion starts, have 2 frames, ever add components instance of aboutinfo
.
the basic answer here is, rid of frame
, it's confusing issue. in fact, shouldn't extending jframe
in first place, should use jpanel
, add instances of class instances of jframe
or jdialog
or ever container want
Comments
Post a Comment