View Javadoc
1   package org.woehlke.computer.kurzweil.tabs.cca.view;
2   
3   import org.woehlke.computer.kurzweil.tabs.cca.config.ObjectRegistry;
4   
5   import javax.accessibility.Accessible;
6   import javax.swing.*;
7   import java.awt.*;
8   import java.awt.event.WindowEvent;
9   import java.awt.event.WindowListener;
10  import java.awt.image.ImageObserver;
11  import java.io.Serializable;
12  
13  /**
14   * Cyclic Cellular Automaton.
15   *
16   * (C) 2006 - 2013 Thomas Woehlke.
17   * http://thomas-woehlke.de/p/cyclic-cellular-automaton/
18   * @author Thomas Woehlke
19   * Date: 04.02.2006
20   * Time: 18:47:46
21   */
22  public class CyclicCellularAutomatonFrame extends JFrame implements ImageObserver,
23          MenuContainer,
24          Serializable,
25          Accessible,
26          WindowListener {
27  
28      private static final long serialVersionUID = 4357793241219932594L;
29  
30      private ObjectRegistry ctx;
31  
32      public CyclicCellularAutomatonFrame(ObjectRegistry ctx) {
33          super(ctx.getConfig().getTitle());
34          this.ctx=ctx;
35          ctx.setFrame(this);
36          BoxLayout layout = new BoxLayout(rootPane, BoxLayout.PAGE_AXIS);
37          rootPane.setLayout(layout);
38          rootPane.add(ctx.getSubtitle());
39          rootPane.add(ctx.getCanvas());
40          rootPane.add(ctx.getPanelButtons());
41          addWindowListener(this);
42          ctx.getController().start();
43          showMe();
44      }
45  
46      public void showMe() {
47          pack();
48          this.setBounds(ctx.getConfig().getFrameBounds());
49          setVisible(true);
50          toFront();
51      }
52  
53      public void windowOpened(WindowEvent e) {
54          showMe();
55      }
56  
57      public void windowClosing(WindowEvent e) {
58          System.exit(0);
59      }
60  
61      public void windowClosed(WindowEvent e) {
62          System.exit(0);
63      }
64  
65      public void windowIconified(WindowEvent e) { }
66  
67      public void windowDeiconified(WindowEvent e) {
68          showMe();
69      }
70  
71      public void windowActivated(WindowEvent e) {
72          toFront();
73      }
74  
75      public void windowDeactivated(WindowEvent e) {
76      }
77  }