-
Frame doesn't appear
Hello,
I'm trying to make a button that when pressed it shows another frame (CustomerOrder) and hides the current one.
private void btnDoneActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new CustomerOrder.setVisible(true);
}
It's not working, only the current frame hides and nothing happens.
Any ideas what the problem could be ?
-
This should cause a compiler error, right?:
Code:
new CustomerOrder.setVisible(true);
Better perhaps is:
Code:
new CustomerOrder().setVisible(true);
Having said this, I much prefer swapping JPanels via a CardLayout than swapping JFrames.
BTW, welcome to the forum.
-
Good advice from F7e regarding CardLayout. As far as chaining method calls... Java obviously allows it, and it's not wrong, but it makes debugging your program more difficult. If adding the () to CustomerOrder fixed the problem, pls mark your post as solved.
-
Thank you so much "Fubarable" and "Steve11235" for your replies. It's now solved :)
I