Methapolis  0.27
 All Classes Namespaces Files Functions Variables Enumerator
EndGamePane.java
Go to the documentation of this file.
1 package micropolisj.gui;
2 
3 import java.awt.BorderLayout;
4 import java.awt.FlowLayout;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7 
8 import javax.swing.JButton;
9 import javax.swing.JFrame;
10 import javax.swing.JLabel;
11 import javax.swing.JPanel;
12 
13 import micropolisj.network.ServerMicropolis;
14 
15 public class EndGamePane extends JFrame {
16 
17  MainWindow mainWindow;
18 
19  public EndGamePane(MainWindow mainWindow){
20  this.mainWindow = mainWindow;
21 
22  setBounds(200, 200, 600, 600);
23 
24  setLayout(new BorderLayout());
25 
26  JLabel endMessageLabel = new JLabel("big win!");
27  add(endMessageLabel, BorderLayout.CENTER);
28 
29  JPanel menu = new JPanel();
30  menu.setLayout(new FlowLayout(FlowLayout.CENTER));
31 
32  JButton newGameButton = new JButton("new game");
33  newGameButton.addActionListener(new ActionListener(){
34  public void actionPerformed(ActionEvent e){
35  startNewGame();
36  }
37  });
38  menu.add(newGameButton);
39 
40  JButton joinGameButton = new JButton("join game");
41  joinGameButton.addActionListener(new ActionListener(){
42  public void actionPerformed(ActionEvent e){
44  }
45  });
46  menu.add(joinGameButton);
47 
48  JButton loadGameButton = new JButton("load game");
49  loadGameButton.addActionListener(new ActionListener(){
50  public void actionPerformed(ActionEvent e){
51  loadGame();
52  }
53  });
54  menu.add(loadGameButton);
55 
56  JButton createServerButton = new JButton("create server");
57  createServerButton.addActionListener(new ActionListener(){
58  public void actionPerformed(ActionEvent e){
60  }
61  });
62  menu.add(createServerButton);
63 
64  JButton continueGameButton = new JButton("continue");
65  continueGameButton.addActionListener(new ActionListener(){
66  public void actionPerformed(ActionEvent e){
67  continueGame();
68  }
69  });
70  menu.add(continueGameButton);
71 
72  add(menu, BorderLayout.SOUTH);
73 
74  setVisible(true);
75  }
76 
77  void closeMainWindow(){
78  mainWindow.closeWindow();
79  mainWindow.makeClean();
80  }
81 
82  private void startJoinGameScreen() {
83  closeMainWindow();
84 
85  new JoinGameScreen();
86  closeThis();
87  }
88 
89  private void startNewGame() {
90  closeMainWindow();
91 
92  MainWindow win = new MainWindow();
93  win.doNewCity(true);
94  this.setVisible(false);
95  win.setVisible(false);
96  win.setVisible(true);
97  closeThis();
98  }
99 
100  private void startNewServer() {
101  closeMainWindow();
102 
103  this.setVisible(false);
104  MainWindow win = new MainWindow(new ServerMicropolis());
105  win.setVisible(false);
106  win.doNewCity(true);
107  win.setVisible(true);
108  closeThis();
109  }
110 
111  private void loadGame() {
112  closeMainWindow();
113 
114  this.setVisible(false);
115  MainWindow win = new MainWindow();
116  win.setVisible(false);
117  win.onLoadGameClicked();
118  win.setVisible(true);
119  closeThis();
120  }
121 
122  private void continueGame(){
123  closeThis();
124  }
125 
126  private void closeThis() {
127  this.setVisible(false);
128  this.dispose();
129  }
130 
131 }