Answer the question
In order to leave comments, you need to log in
How to display one component on top of another in Java Swing?
There is a window:
class Window extends JFrame {
int width = 1500;
int height = 750;
private JPanel mainPanel;
private JPanel mapPanel;
private JPanel pausePanel;
Window() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLayout(null);
setSize(width + 5, height + 28);
setResizable(false);
setLocation((screenSize.width-getWidth())/2, (screenSize.height-getHeight())/2);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
mainPanel = new MainPanel();
mapPanel = new MapPanel();
pausePanel = new PausePanel();
add(mainPanel);
mainPanel.add(mapPanel);
mainPanel.add(pausePanel);
repaint();
}
void showPauseMenu () {
pausePanel.setVisible(true);
}
void hidePauseMenu () {
pausePanel.setVisible(false);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question