View Javadoc
1   package org.woehlke.simulation.dla.view.desktop;
2   
3   import org.woehlke.simulation.dla.DiffusionLimitedAggregation;
4   import org.woehlke.simulation.dla.view.applet.DiffusionLimitedAggregationApplet;
5   
6   import javax.accessibility.Accessible;
7   import javax.swing.*;
8   import java.awt.*;
9   import java.awt.event.WindowEvent;
10  import java.awt.event.WindowListener;
11  import java.awt.image.ImageObserver;
12  import java.io.Serializable;
13  
14  /**
15   * Diffusion Limited Aggregation.
16   *
17   * (C) 2006 - 2013 Thomas Woehlke.
18   * https://thomas-woehlke.blogspot.com/2016/01/diffusion-limited-aggregation.html
19   * @author Thomas Woehlke
20   *
21   * Date: 04.02.2006
22   * Time: 18:47:46
23   */
24  public class DiffusionLimitedAggregationFrame extends JFrame implements ImageObserver,
25          MenuContainer,
26          Serializable,
27          Accessible,
28          WindowListener, DiffusionLimitedAggregation {
29  
30      static final long serialVersionUID = mySerialVersionUID;
31  
32  
33      private DiffusionLimitedAggregationApplet exe;
34  
35      public DiffusionLimitedAggregationFrame() {
36          super(TITLE);
37          exe = new DiffusionLimitedAggregationApplet();
38          exe.init();
39          add("Center", exe);
40          setBounds(100, 100, exe.getCanvasDimensions().getX(), exe.getCanvasDimensions().getY() + 30);
41          pack();
42          setVisible(true);
43          toFront();
44          addWindowListener(this);
45      }
46  
47      public void windowOpened(WindowEvent e) {
48          setBounds(100, 100, exe.getCanvasDimensions().getX(), exe.getCanvasDimensions().getY() + 30);
49          setVisible(true);
50          toFront();
51      }
52  
53      public void windowClosing(WindowEvent e) {
54          System.exit(0);
55      }
56  
57      public void windowClosed(WindowEvent e) {
58          System.exit(0);
59      }
60  
61      public void windowIconified(WindowEvent e) {
62  
63      }
64  
65      public void windowDeiconified(WindowEvent e) {
66          setBounds(100, 100, exe.getCanvasDimensions().getX(), exe.getCanvasDimensions().getY() + 30);
67          setVisible(true);
68          toFront();
69      }
70  
71      public void windowActivated(WindowEvent e) {
72          toFront();
73      }
74  
75      public void windowDeactivated(WindowEvent e) {
76      }
77  }