@@ -39,12 +39,14 @@ public class DiffusionLimitedAggregationFrame extends JFrame implements ImageObs
3939
4040 static final long serialVersionUID = 242L ;
4141
42- private JLabel subtitle ;
43- private JLabel copyright ;
44- private ControllerThread controller ;
45- private WorldCanvas canvas ;
46- private DiffusionLimitedAggregationModel model ;
47- private ComputerKurzweilProperties config ;
42+ private final JLabel subtitle ;
43+ private final JLabel copyright ;
44+ private volatile ControllerThread controller ;
45+ private volatile WorldCanvas canvas ;
46+ private volatile DiffusionLimitedAggregationModel model ;
47+ private volatile ComputerKurzweilProperties config ;
48+ private volatile Rectangle rectangleBounds ;
49+ private volatile Dimension dimensionSize ;
4850
4951 public DiffusionLimitedAggregationFrame (ComputerKurzweilProperties config ) {
5052 super (config .getDla ().getView ().getTitle ());
@@ -58,21 +60,47 @@ public DiffusionLimitedAggregationFrame(ComputerKurzweilProperties config) {
5860 this .add (subtitle , BorderLayout .NORTH );
5961 this .add (canvas , BorderLayout .CENTER );
6062 this .add (copyright , BorderLayout .SOUTH );
61- showMe ();
63+ showMeInit ();
6264 addWindowListener (this );
6365 }
6466
6567 public void start () {
6668 controller .start ();
6769 }
6870
69- public void showMe (){
70- setBounds (getFrameBounds ());
71+ public void showMeInit () {
7172 pack ();
73+ Dimension screenSize = Toolkit .getDefaultToolkit ().getScreenSize ();
74+ double width = this .model .getWorldDimensions ().getX ();
75+ double height = this .model .getWorldDimensions ().getY () + 60 ;
76+ double startX = (screenSize .getWidth () - width ) / 2d ;
77+ double startY = (screenSize .getHeight () - height ) / 2d ;
78+ int myheight = Double .valueOf (height ).intValue ();
79+ int mywidth = Double .valueOf (width ).intValue ();
80+ int mystartX = Double .valueOf (startX ).intValue ();
81+ int mystartY = Double .valueOf (startY ).intValue ();
82+ this .rectangleBounds = new Rectangle (mystartX , mystartY , mywidth , myheight );
83+ this .dimensionSize = new Dimension (mywidth , myheight );
84+ this .setBounds (this .rectangleBounds );
85+ this .setSize (this .dimensionSize );
86+ this .setPreferredSize (this .dimensionSize );
87+ this .setDefaultCloseOperation (WindowConstants .EXIT_ON_CLOSE );
7288 setVisible (true );
7389 toFront ();
7490 }
7591
92+ /**
93+ * Things to do, to show the Application Window again.
94+ */
95+ public void showMe () {
96+ this .pack ();
97+ this .setBounds (this .rectangleBounds );
98+ this .setSize (this .dimensionSize );
99+ this .setPreferredSize (this .dimensionSize );
100+ this .setVisible (true );
101+ this .toFront ();
102+ }
103+
76104 public Rectangle getFrameBounds () {
77105 int height = this .model .getWorldDimensions ().getY ();
78106 int width = this .model .getWorldDimensions ().getX ();
0 commit comments