I'm making a Game where I have to DrawingComponent painting everything related to the game. Now I want to add a "close" button over the DrawingComponent.
public class SimulationWindow extends JFrame
{
private static final long serialVersionUID = 1L;
public SimulationWindow()
{
super("Game");
setUndecorated(true);
setExtendedState(JFrame.MAXIMIZED_BOTH);
getContentPane().setBackground(Color.BLACK);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton closeButton = new JButton();
closeButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0) {
Game.close = true;
}
});
add(new DrawingComponent());
add(closeButton);
setVisible(true);
}
}
But it's just a grey area that pops up. The DrawingComponent which is essentially the game is not visible.