Source code: org/zazof/jteg/gui/MainFrame.java
1 package org.zazof.jteg.gui;
2
3 import java.util.Vector;
4 import javax.swing.*;
5 import java.awt.*;
6 import java.awt.event.*;
7 import org.zazof.jteg.*;
8
9 /**
10 * Mainframe is the central GUIclass. It is the container of all other GUI objects.
11 * <br>
12 *
13 * @author Yves Vandewoude
14 * @author Jef De Geeter
15 */
16
17
18
19 public class MainFrame extends JFrame implements WindowListener, MessageListener{
20
21 /**
22 * Constructor of the MainFrame class.
23 *
24 */
25 public MainFrame(){
26 // Initial buildup of the MainFraim
27 super();
28 $frameWidth = 640;
29 $frameHeight = 570;
30 setTitle($title);
31 setSize($frameWidth, $frameHeight);
32 $boardCanvas = new BoardCanvas();
33
34 // Placing armies: the inputlistener and the visualizer.
35 $placeArmiesMouseInput = new PlaceArmiesMouseInput(this, $boardCanvas);
36 JTEGStateMachine.getInstance().subscribe($placeArmiesMouseInput);
37 $boardCanvas.registerVisualizer(new PlaceArmiesVisualizer($placeArmiesMouseInput));
38
39
40 $attaqueMouseInput = new AttaqueMouseInput($boardCanvas);
41 $regroupMouseInput = new RegroupMouseInput(this, $boardCanvas);
42 if (DEBUG) System.out.println("Starting up...");
43 startup();
44 addWindowListener(this);
45 MessageManager.getInstance().addMessageListener(this);
46 if (DEBUG) System.out.println("Showing connectiondialog...");
47 showConnectionDialog();
48 if (DEBUG) System.out.println("Initcards...");
49 initCards();
50 if (DEBUG) System.out.println("Initmission...");
51 initMission();
52 }
53
54 /*
55 * Helpmethod to 'startup' the GUI.
56 * - Creates and registers a toolbar
57 * - Creates and registers a menubar
58 * Adds toolbar, menubar, chatpanel to the MainFrame
59 */
60
61 private void startup(){
62 // This first line is required in order for the menu to draw it's menus on top of the
63 // boardcanvas. By forcing these 'popupmenus' to be heavyweight, they get their own
64 // frame and are drawn on top.
65 // For mor information on the problem and on the solution, see:
66 // http://java.sun.com/products/jfc/tsc/articles/mixing/index.html
67 JPopupMenu.setDefaultLightWeightPopupEnabled(false);
68
69 getContentPane().setLayout(new BorderLayout());
70
71 // We create the toolbar
72 ToolBar toolbar = new ToolBar(this);
73 // We register it with the statemachine
74 JTEGStateMachine.getInstance().subscribe(toolbar);
75 // We register it with the languagemanager
76 LanguageManager.getInstance().subscribe(toolbar);
77 // We add it to our contentpane
78 getContentPane().add(toolbar, BorderLayout.NORTH);
79
80 // We create the menubar
81 MenuBar menubar = new MenuBar(this);
82 // We register it with the statemachine
83 JTEGStateMachine.getInstance().subscribe(menubar);
84 // We register it with the languageManager
85 LanguageManager.getInstance().subscribe(menubar);
86 // We set it to be the menubar of our GUI
87 setJMenuBar(menubar);
88
89
90 JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
91 split.add($boardCanvas, JSplitPane.TOP);
92
93 JPanel bottom = new JPanel();
94 bottom.setLayout(new BorderLayout());
95
96 // We give the scrollbar to the chatpanel. It's usefull for automatic scrolling.
97 JScrollPane scrollPane = new JScrollPane($chatPanel);
98 JScrollBar scrollbar = scrollPane.getVerticalScrollBar();
99 $chatPanel.setScrollBar(scrollbar);
100
101 bottom.add(scrollPane, BorderLayout.CENTER);
102 InputTextField inputField = new InputTextField();
103 JTEGStateMachine.getInstance().subscribe(inputField);
104 bottom.add(inputField, BorderLayout.SOUTH);
105 split.add(bottom, JSplitPane.BOTTOM);
106 getContentPane().add(split, BorderLayout.CENTER);
107 }
108
109
110 /*
111 * Responsible for the startup of the Card-GUI objects, which are responsible for showing the cards of the player
112 *
113 */
114
115
116 private void initCards(){
117 $cardsFrame = new JFrame();
118 $cardsFrame.getContentPane().setLayout(new BorderLayout());
119 CardContainerCanvas ccc = new CardContainerCanvas($cardsFrame);
120 $cardsFrame.getContentPane().add(ccc, BorderLayout.CENTER);
121 CardButtonBar cardButtonBar = new CardButtonBar($cardsFrame, this, ccc);
122 // We register it with the statemachine
123 JTEGStateMachine.getInstance().subscribe(cardButtonBar);
124 // We register it with the languagemanager
125 LanguageManager.getInstance().subscribe(cardButtonBar);
126
127 $cardsFrame.getContentPane().add(cardButtonBar, BorderLayout.NORTH);
128 $cardsFrame.setTitle(LanguageManager.getInstance().lookup("cardsframetitle"));
129 }
130
131 /*
132 * Responsible for the startup of the Mission-screen which shows the player his mission
133 *
134 */
135 private void initMission(){
136 $missionFrame = new JFrame();
137 $missionFrame.getContentPane().setLayout(new BorderLayout());
138 MissionCanvas mc = new MissionCanvas($missionFrame);
139 $missionFrame.getContentPane().add(mc, BorderLayout.CENTER);
140 MessageManager.getInstance().addMessageListener(mc);
141 }
142
143
144 /*
145 * Implementation of the MessageListener Interface.
146 * <br>
147 * MainFrame will respond to a number of messages, and will handle the GUI-actions following this event.
148 *
149 */
150
151 public void messageArrived(Message m){
152 try{
153 if ((JTEGStateMachine.getInstance().getCurrentState() == JTEGStateMachine.CHOOSING_COLORS) && m.getMessageName().equals("status")){
154 if (DEBUG) System.out.println("Received status during choosing color");
155 Vector occupied = GameController.getInstance().getPlayerList().getOccupiedPlayerColors();
156 $colorChooserDialog.setOccupiedColors(occupied);
157 $colorChooserDialog.repaint();
158 }
159 if ((JTEGStateMachine.getInstance().getCurrentState() == JTEGStateMachine.CHOOSING_COLORS) && m.getMessageName().equals("new_player")){
160 if (DEBUG) System.out.println("Received new_player during choosing color");
161 Vector occupied = GameController.getInstance().getPlayerList().getOccupiedPlayerColors();
162 $colorChooserDialog.setOccupiedColors(occupied);
163 $colorChooserDialog.repaint();
164 }
165 // the game is busy and we can't connect as a player
166 if (m.getMessageName().equals("busy")){
167 // display JOptionPane and connect as observer
168 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("serverbusy"),LanguageManager.getInstance().lookup("busy"), JOptionPane.INFORMATION_MESSAGE);
169 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.DISCONNECTED);
170 // the action to connect as observer should come here.
171 }
172 if (m.getMessageName().equals("turno")){
173 TurnMessage tm = (TurnMessage) m;
174 // check whether it is currently the clientplayer's turn to play
175 Player p = GameController.getInstance().getClientPlayer();
176 if (p.getID() == tm.getPlayerID()){
177 // it's our turn to play
178 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("yourturntoattack"), LanguageManager.getInstance().lookup("attack"), JOptionPane.INFORMATION_MESSAGE);
179 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.ATTACKING);
180 $boardCanvas.addMouseListener($attaqueMouseInput);
181 $boardCanvas.addMouseMotionListener($attaqueMouseInput);
182 // enable regroup, get_card and end_turn
183 }
184 }
185 // we may place some armies onto the board
186 if (m.getMessageName().equals("fichas")){
187 // Convert into a message
188 PlaceArmiesMessage pam = (PlaceArmiesMessage) m;
189
190 // Check whether it is us, or someone else that may exchange.
191 Player p = GameController.getInstance().getClientPlayer();
192 if (pam.getPlayerID() == p.getID()){
193 // It's us !!!
194 // Set the continents this player owns.
195 int continents = pam.getContinents();
196
197 String initialPlaceArmiesString = LanguageManager.getInstance().lookup("placexarmies" , Integer.toString(pam.getArmies()));
198 String continentString = LanguageManager.getInstance().lookup("placeadditional") + "\n";
199 if ((continents & 0x1) == 0x1) continentString += " " + LanguageManager.getInstance().lookup("place_sa") + "\n";
200 if ((continents & 0x2) == 0x2) continentString += " " + LanguageManager.getInstance().lookup("place_na") + "\n";
201 if ((continents & 0x4) == 0x4) continentString += " " + LanguageManager.getInstance().lookup("place_af") + "\n";
202 if ((continents & 0x8) == 0x8) continentString += " " + LanguageManager.getInstance().lookup("place_oc") + "\n";
203 if ((continents & 0x10) == 0x10) continentString +=" " + LanguageManager.getInstance().lookup("place_eur") + "\n";
204 if ((continents & 0x20) == 0x20) continentString += " " + LanguageManager.getInstance().lookup("place_asia");
205
206 if (continents != 0) initialPlaceArmiesString += "\n" + continentString;
207
208 // Now we first need to check whether this player CAN exchange his cards. If he can, he must do so now...
209 if (GameController.getInstance().getCardController().canExchange()){
210 $currentPlaceArmiesMessage = pam;
211 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.EXCHANGING_CARDS);
212 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("changecardsnow"), LanguageManager.getInstance().lookup("exchangecards"), JOptionPane.INFORMATION_MESSAGE);
213 $cardsFrame.setVisible(true);
214 }
215 if (!(JTEGStateMachine.getInstance().getCurrentState() == JTEGStateMachine.EXCHANGING_CARDS))
216 {
217 JOptionPane.showMessageDialog(this, initialPlaceArmiesString, LanguageManager.getInstance().lookup("placearmies"), JOptionPane.INFORMATION_MESSAGE);
218 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.PLACING_ARMIES);
219 }
220 $placeArmiesMouseInput.setContinentArmies(continents);
221 $placeArmiesMouseInput.setUnconditionalArmies(pam.getArmies());
222 $placeArmiesMouseInput.fixateArmies();
223 $boardCanvas.addMouseListener($placeArmiesMouseInput);
224 $boardCanvas.addMouseMotionListener($placeArmiesMouseInput);
225 }
226 }
227 // hmmm we do have a looser :-D
228 if (m.getMessageName().equals("loser")){
229 LoserMessage lm = (LoserMessage) m;
230 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("playerthatlost", lm.getLoser().getName()), LanguageManager.getInstance().lookup("loser"), JOptionPane.INFORMATION_MESSAGE);
231 }
232 // hmmm we do have a winner :-D
233 if (m.getMessageName().equals("winner")){
234 WinnerMessage lm = (WinnerMessage) m;
235 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("playerthatwon", lm.getWinner().getName()), LanguageManager.getInstance().lookup("winner"), JOptionPane.INFORMATION_MESSAGE);
236 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.CONNECTED);
237 }
238 // we conquered a country and may regroup after attack some armies
239 if (m.getMessageName().equals("tropas")){
240 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.MOVING_AFTER_ATTACK);
241 RegroupAfterAttackMessage raam = (RegroupAfterAttackMessage) m;
242 String conquered_country = GameController.getInstance().getCountryList().getCountry(raam.getToCountry()).getCountryName();
243 String mess = ""; String inputValue = "0";
244 switch(raam.getMaxArmies()){
245 case 0:
246 mess = LanguageManager.getInstance().lookup("conquered", conquered_country);
247 JOptionPane.showMessageDialog(this, mess, LanguageManager.getInstance().lookup("countryconquered"), JOptionPane.INFORMATION_MESSAGE);
248 break;
249 default:
250 mess = LanguageManager.getInstance().lookup("conquered", conquered_country);
251 mess += "\n" + LanguageManager.getInstance().lookup("maximummoveallowed", Integer.toString(raam.getMaxArmies()));
252 inputValue = JOptionPane.showInputDialog(this, mess, LanguageManager.getInstance().lookup("countryconquered"), JOptionPane.INFORMATION_MESSAGE);
253 if (DEBUG) System.out.println("Input value from A country was conquered: " + inputValue);
254 int input = 0;
255 if (inputValue.equals("")){
256 input = 0;
257 }else{
258 input = Integer.parseInt(inputValue);
259 if (input > raam.getMaxArmies()) input = raam.getMaxArmies();
260 if (input < 0) input = 0;
261 }
262 String[] params = { "regroupafterattack", Integer.toString(raam.getFromCountry()), Integer.toString(raam.getToCountry()), Integer.toString(input)};
263 MessageManager.getInstance().sendToServer(params);
264 }
265 }
266 if (m.getMessageName().equals("tarjeta"))
267 // We receive a message telling us that we just received a card.
268 // We only need to do the GUI portion, which is setting the cardframe visible
269 {
270 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.GETTING_CARD);
271 $cardsFrame.setVisible(true);
272 }
273 // We receive a message telling that someone has exchanged cards
274 // Next to the MainFrame, the CardController will also listen to this message
275 // Therefore, the action that needs to be done will be done by both classes
276 // This class will only handle GUI events and placing armies
277 // The CardController will remove the cards from the possession of the player if necessary.
278 if (m.getMessageName().equals("canje"))
279 {
280 ExchangeCardMessage em = (ExchangeCardMessage) m;
281
282 // We check whether the player that has exchanged cards is us, or someone else
283 Player clientPlayer = GameController.getInstance().getClientPlayer();
284
285 if (clientPlayer.getID() == em.getPlayerID())
286 {
287 // It's us...
288 // To force that the "cards which are removed are in fact no longer drawn :)"
289 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.EXCHANGING_CARDS);
290 $cardsFrame.setVisible(false);
291
292 // Remove the cards from the players posession: Done by CardController
293 // Give him the armies
294 String initialPlaceArmiesString = LanguageManager.getInstance().lookup("placexarmies" , Integer.toString(($placeArmiesMouseInput.getNbUnconditionalArmies())));
295 String continentString = "";
296 int totalContinentalArmies = $placeArmiesMouseInput.getNbContinentalArmies(0) + $placeArmiesMouseInput.getNbContinentalArmies(1) +
297 $placeArmiesMouseInput.getNbContinentalArmies(2) + $placeArmiesMouseInput.getNbContinentalArmies(3) +
298 $placeArmiesMouseInput.getNbContinentalArmies(4) + $placeArmiesMouseInput.getNbContinentalArmies(5);
299 if (totalContinentalArmies > 0)
300 {
301 continentString = LanguageManager.getInstance().lookup("placeadditional") + "\n";
302 if ($placeArmiesMouseInput.getNbContinentalArmies(0) > 0) continentString += " " + LanguageManager.getInstance().lookup("place_sa") + "\n";
303 if ($placeArmiesMouseInput.getNbContinentalArmies(1) > 0) continentString += " " + LanguageManager.getInstance().lookup("place_na") + "\n";
304 if ($placeArmiesMouseInput.getNbContinentalArmies(2) > 0) continentString += " " + LanguageManager.getInstance().lookup("place_af") + "\n";
305 if ($placeArmiesMouseInput.getNbContinentalArmies(3) > 0) continentString += " " + LanguageManager.getInstance().lookup("place_oc") + "\n";
306 if ($placeArmiesMouseInput.getNbContinentalArmies(4) > 0) continentString += " " + LanguageManager.getInstance().lookup("place_eur") + "\n";
307 if ($placeArmiesMouseInput.getNbContinentalArmies(5) > 0) continentString += " " + LanguageManager.getInstance().lookup("place_asia") + "\n";
308 }
309
310 if (!(continentString.equals("")))
311 {
312 initialPlaceArmiesString += "\n" + continentString;
313 }
314
315 initialPlaceArmiesString += LanguageManager.getInstance().lookup("extrafromcards",Integer.toString(em.getNbOfArmies()));
316 initialPlaceArmiesString += "\n" + LanguageManager.getInstance().lookup("totalnrofarmies",Integer.toString((em.getNbOfArmies()+ $currentPlaceArmiesMessage.getArmies() + totalContinentalArmies)));
317
318 JOptionPane.showMessageDialog(this, initialPlaceArmiesString, LanguageManager.getInstance().lookup("placearmies"), JOptionPane.INFORMATION_MESSAGE);
319
320 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.PLACING_ARMIES);
321 // Remember, the correct MouseListener was already added to the system.
322 if (DEBUG) System.out.println("I will set armies to place to " + (em.getNbOfArmies()+$currentPlaceArmiesMessage.getArmies()));
323
324 $placeArmiesMouseInput.setNbCardArmies(em.getNbOfArmies());
325 $placeArmiesMouseInput.fixateArmies();
326 if (DEBUG)
327 {
328 System.out.println("Number Of SA continental Armies = " + $placeArmiesMouseInput.getNbContinentalArmies(0));
329 System.out.println("Number Of NA continental Armies = " + $placeArmiesMouseInput.getNbContinentalArmies(1));
330 System.out.println("Number Of AF continental Armies = " + $placeArmiesMouseInput.getNbContinentalArmies(2));
331 System.out.println("Number Of OC continental Armies = " + $placeArmiesMouseInput.getNbContinentalArmies(3));
332 System.out.println("Number Of EU continental Armies = " + $placeArmiesMouseInput.getNbContinentalArmies(4));
333 System.out.println("Number Of AS continental Armies = " + $placeArmiesMouseInput.getNbContinentalArmies(5));
334 System.out.println("Number of ordinary armies: " + $placeArmiesMouseInput.getNbUnconditionalArmies());
335 System.out.println("Number of cardArmies: " + $placeArmiesMouseInput.getNbCardArmies());
336 }
337 }
338 else
339 {
340 // Someone else received armies due to a card-exchange
341 // All we do is mention this to our player
342
343 PlayerList pl = GameController.getInstance().getPlayerList();
344 String playerName = (pl.getPlayer(em.getPlayerID())).getName();
345
346 $chatPanel.writeMessage(LanguageManager.getInstance().lookup("playerexchanged", playerName) + LanguageManager.getInstance().lookup("hereceivedxarmies", Integer.toString(em.getNbOfArmies())));
347 }
348 }
349 if (m.getMessageName().equals("error"))
350 {
351 ErrorMessage em = (ErrorMessage) m;
352 if (DEBUG) System.out.println("Error detected: " + em.getError());
353 if (((em.getError()).equals("fichasc")) || ((em.getError()).equals("fichas"))
354 || ((em.getError()).equals("fichas2")))
355 {
356 // Ok.. Something went wrong in placing the armies... :'(
357 $placeArmiesMouseInput.restoreToFix(); // Go back to where you were...
358
359 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("illegalarmiesplaced"), LanguageManager.getInstance().lookup("wrongplacement"), JOptionPane.INFORMATION_MESSAGE);
360 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.PLACING_ARMIES);
361 $boardCanvas.addMouseListener($placeArmiesMouseInput);
362 $boardCanvas.addMouseMotionListener($placeArmiesMouseInput);
363 }
364 if (em.getError().equals("start"))
365 {
366 JOptionPane.showMessageDialog(this, LanguageManager.getInstance().lookup("lessthantwoplayers"), LanguageManager.getInstance().lookup("error"), JOptionPane.INFORMATION_MESSAGE);
367 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.CONNECTED);
368 }
369 }
370 }
371 catch (Exception e){
372 e.printStackTrace();
373 }
374 }
375
376 /**
377 * called by PlaceArmiesMouseInput when the armies are in place
378 */
379 void armiesPlaced(String[] armiesData){
380 $boardCanvas.removeMouseListener($placeArmiesMouseInput);
381 $boardCanvas.removeMouseMotionListener($placeArmiesMouseInput);
382 $sendArmies = armiesData;
383 }
384
385 /**
386 * the user requested to sent the armies, called by toolbar or menubar
387 */
388 void sendArmies(){
389 try{
390 // What happens if the user placed the wrong nb of armies? The server
391 // responds with an error message.
392 MessageManager.getInstance().sendToServer($sendArmies);
393 MessageManager.getInstance().askPlayerStatus();
394 }
395 catch (Exception e){
396 e.printStackTrace();
397 }
398 }
399
400
401
402 /**
403 * called by RegroupMouseInput
404 */
405 void regroup(Country from, Country to){
406 String inputValue;
407 try{
408 inputValue = JOptionPane.showInputDialog(this,
409 LanguageManager.getInstance().lookup("countryorigin", from.getCountryName()) + "\n" +
410 LanguageManager.getInstance().lookup("countrydest", to.getCountryName()) + "\n" +
411 LanguageManager.getInstance().lookup("regrouphowmany", to.getCountryName()) + "\n",
412 LanguageManager.getInstance().lookup("regrouparmies", to.getCountryName()), JOptionPane.QUESTION_MESSAGE);
413 if ((inputValue != null) && (!(inputValue.equals(""))))
414 {
415 String[] params = { "regrouparmies", Integer.toString(from.getID()), Integer.toString(to.getID()), inputValue };
416 MessageManager.getInstance().sendToServer(params);
417 }
418 }
419 catch (Exception e){
420 e.printStackTrace();
421 }
422 }
423
424 /**
425 * the user requested to regroup, called by toolbar or menubar
426 */
427 void prepareRegroup(){
428 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.REGROUPING_ARMIES);
429 $boardCanvas.removeMouseListener($attaqueMouseInput);
430 $boardCanvas.removeMouseMotionListener($attaqueMouseInput);
431 $boardCanvas.addMouseListener($regroupMouseInput);
432 $boardCanvas.addMouseMotionListener($regroupMouseInput);
433 }
434
435
436 /**
437 * the user requested to get a card, called by toolbar or menubar
438 */
439 void getCard(){
440 // disable regroup, get card button
441 try{
442 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.GETTING_CARD);
443 $boardCanvas.removeMouseListener($attaqueMouseInput);
444 $boardCanvas.removeMouseMotionListener($attaqueMouseInput);
445 String[] params = {"getcard"};
446 MessageManager.getInstance().sendToServer(params);
447 }
448 catch (Exception e){
449 e.printStackTrace();
450 }
451 }
452
453 void removeRegroupMouseListeners()
454 {
455 $boardCanvas.removeMouseListener($regroupMouseInput);
456 $boardCanvas.removeMouseMotionListener($regroupMouseInput);
457 }
458
459
460 void showConnectionDialog(){
461 ConnectDialog connectDialog = new ConnectDialog(this);
462 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.CONNECTING);
463 connectDialog.show();
464
465 }
466
467 /**
468 * called by ColorChooserDialog
469 */
470 void colorChosen(int color){
471 try{
472 String[] params = {"setcolor", Integer.toString(color)};
473 MessageManager.getInstance().sendToServer(params);
474 JTEGStateMachine.getInstance().setCurrentState(JTEGStateMachine.CONNECTED);
475 // enable the start button
476 }
477 catch (Exception e){
478 e.printStackTrace();
479 }
480 }
481
482
483 public void showColorchooserDialog(){
484 if (DEBUG) System.out.println("MainFrame.show_colorchooser_dialog");
485 $colorChooserDialog.show();
486 }
487
488 public void showCardFrame(){
489 $cardsFrame.setVisible(true);
490 }
491
492 public void showMissionFrame(){
493 $missionFrame.setVisible(true);
494 }
495
496 public void hideCardFrame(){
497 $cardsFrame.setVisible(false);
498 }
499
500 // implementation of interface WindowListener
501 public void windowOpened(WindowEvent we){
502 }
503
504 public void windowClosing(WindowEvent we){
505 if (DEBUG) System.out.println("JTEG is exiting");
506 System.exit(0);
507 }
508
509 public void windowClosed(WindowEvent we){
510 }
511
512 public void windowIconified(WindowEvent we){
513 }
514
515 public void windowDeiconified(WindowEvent we){
516 }
517
518 public void windowActivated(WindowEvent we){
519 }
520
521 public void windowDeactivated(WindowEvent we){
522 }
523
524
525
526 // private datamembers
527
528 private String $title = "J-TEG - A Java Risk Clone by zazof & stcham";
529 private int $frameWidth;
530 private int $frameHeight;
531 private static final boolean DEBUG = false;
532 private BoardCanvas $boardCanvas;
533 private ChatPanel $chatPanel = new ChatPanel();
534 private PlaceArmiesMouseInput $placeArmiesMouseInput;
535 private AttaqueMouseInput $attaqueMouseInput;
536 private RegroupMouseInput $regroupMouseInput;
537 // contains information on which countries armies are placed
538 private String[] $sendArmies;
539 private JFrame $cardsFrame;
540 private JFrame $missionFrame;
541 private PlaceArmiesMessage $currentPlaceArmiesMessage;
542 private ColorChooserDialog $colorChooserDialog = new ColorChooserDialog(this);
543
544 }