// Une JWindow pour le Menu:
SwingUtilities.invokeLater(new Runnable() {
public void run() {
//On crée une nouvelle instance de notre JWindow
final JWindow startMenu = new JWindow();
startMenu.setSize(550, 400); // On lui donne une taille pour la voir
startMenu.setLocationRelativeTo(null);// On centre le menu
Panel content = new Panel();
startMenu.getContentPane().add(content);
startMenu.setVisible(true); // On l'a rend visible
content.setBackground(new Color(212,154,76));
JLabel title = new JLabel("Tower Carlotta Towa");
title.setPreferredSize(new Dimension(380, 50));
title.setBounds(120,10,380,50);
Font font = new Font("Serif", Font.PLAIN, 32);
title.setFont(font);
content.add(title);
JButton startGame = new JButton("Start the Game !");
content.setLayout(null);
startGame.setBounds(200, 200, 160, 25);
startGame.setBackground(new Color(108,146,212));
startGame.setBorderPainted(false);
content.add(startGame);
startGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// We create the new instance of the JFrame to run the game
AppliWindow window;
try {
// AppliWindow is a Singleton
window = AppliWindow.getInstance();
window.init("Tower-IMAC Carlotta Towa", 800, 700, true, Theme.pathImageMap);
window.setVisible(true); // And we make it visible
} catch (MapFileException e) {
e.printStackTrace();
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (RealPlayerException e) {
e.printStackTrace();
}
}
});
//We hide the menu starter
startMenu.dispose();
}
});
JButton quitGame = new JButton("Exit");