Reputation: 101
Try to make start game after click "Start".
How can I start game inside same window?
public class Object extends JFrame {
public Object() {
setLayout(new FlowLayout());
add(new Main());
// add(new Board());
pack();
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setMinimumSize(new Dimension(getWidth(), getHeight()));
setVisible(true);
}
public static void main(String[] args) {
new Object();
}
}
Upvotes: 0
Views: 71
Reputation: 324197
Use a CardLayout
. You can swap panels when you click the button.
Read the section from the Swing tutorial on How to Use CardLayout for more information and working examples.
Upvotes: 3