1 package micropolisj.gui;
3 import java.awt.Dimension;
4 import java.awt.Graphics;
5 import java.awt.event.MouseEvent;
6 import java.awt.event.MouseListener;
7 import java.awt.image.BufferedImage;
9 import java.io.IOException;
10 import java.util.ResourceBundle;
12 import javax.imageio.ImageIO;
13 import javax.swing.ImageIcon;
14 import javax.swing.JFrame;
15 import javax.swing.JLabel;
16 import javax.swing.JPanel;
18 import micropolisj.engine.Micropolis;
19 import micropolisj.network.ServerMicropolis;
30 JLabel jlStartNewGame;
35 static final ResourceBundle strings =
MainWindow.strings;
38 super(
"Welcome To Methapolis");
40 image = ImageIO.read(
new File(
"graphics/splash.png"));
41 jlStartNewGame =
new JLabel(
new ImageIcon(ImageIO.read(
new File(
"graphics/splash_1.png"))));
42 jlHostGame =
new JLabel(
new ImageIcon(ImageIO.read(
new File(
"graphics/splash_2.png"))));
43 jlLoginGame =
new JLabel(
new ImageIcon(ImageIO.read(
new File(
"graphics/splash_3.png"))));
44 jlLoadGame =
new JLabel(
new ImageIcon(ImageIO.read(
new File(
"graphics/splash_4.png"))));
46 catch(IOException e) {
50 jlSplashImage =
new JLabel(
new ImageIcon(image));
51 jlSplashImage.setBounds(0, 0, 1024, 576);
52 jlStartNewGame.setBounds(0, 0, 1024, 576);
53 jlHostGame.setBounds(0, 0, 1024, 576);
54 jlLoginGame.setBounds(0, 0, 1024, 576);
55 jlLoadGame.setBounds(0, 0, 1024, 576);
57 panel =
new JPanel(null,
true);
58 panel.setSize(1024, 576);
59 getContentPane().add(panel);
60 panel.add(jlSplashImage);
62 panelNewGame =
new JPanel(null,
true);
63 panelNewGame.setBounds(775, 40, 225, 55);
65 panelNewGame.addMouseListener(handlernew);
66 panel.add(panelNewGame);
68 panelHost =
new JPanel(null,
true);
69 panelHost.setBounds(895, 175, 125, 40);
71 panelHost.addMouseListener(handlerhost);
74 panelLogin =
new JPanel(null,
true);
75 panelLogin.setBounds(875, 320, 110, 45);
77 panelLogin.addMouseListener(handlerlog);
78 panel.add(panelLogin);
80 panelLoad =
new JPanel(null,
true);
81 panelLoad.setBounds(755, 500, 230, 55);
83 panelLoad.addMouseListener(handlerload);
86 final Dimension d = this.getToolkit().getScreenSize();
88 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
89 this.setSize(1024, 576);
90 this.setResizable(
false);
91 this.setLocationRelativeTo(null);
92 this.setUndecorated(
true);
93 this.setVisible(
true);
105 this.setVisible(
false);
106 win.setVisible(
false);
107 win.setVisible(
true);
112 this.setVisible(
false);
114 win.setVisible(
false);
116 win.setVisible(
true);
121 this.setVisible(
false);
123 win.setVisible(
false);
125 win.setVisible(
true);
130 this.setVisible(
false);
148 panel.remove(jlSplashImage);
150 panel.add(jlStartNewGame);
156 panel.remove(jlStartNewGame);
158 panel.add(jlSplashImage);
178 panel.remove(jlSplashImage);
180 panel.add(jlHostGame);
186 panel.remove(jlHostGame);
188 panel.add(jlSplashImage);
208 panel.remove(jlSplashImage);
210 panel.add(jlLoginGame);
216 panel.remove(jlLoginGame);
218 panel.add(jlSplashImage);
238 panel.remove(jlSplashImage);
240 panel.add(jlLoadGame);
246 panel.remove(jlLoadGame);
248 panel.add(jlSplashImage);
255 super.paintComponents(g);
256 g.drawImage(image, 0, 0, null);
259 void startPlaying(
Micropolis newEngine, File file) {
262 win.setVisible(
true);
264 win.currentFile = file;
270 panel.remove(panelNewGame);
271 panel.remove(panelHost);
272 panel.remove(panelLogin);
273 panel.remove(panelLoad);
278 panel.add(panelNewGame);
279 panel.add(panelHost);
280 panel.add(panelLogin);
281 panel.add(panelLoad);