File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .awt .Toolkit ;
12import java .io .File ;
23import java .io .FileNotFoundException ;
34import java .util .ArrayList ;
@@ -92,23 +93,25 @@ public static Grid readFile(String path) {
9293 */
9394 public static void main (String [] args ) {
9495
95- // create the grid
96+ // create the grid drawing
9697 Grid grid ;
9798 if (args .length != 1 ) {
9899 grid = example ();
99100 } else {
100101 grid = readFile (args [0 ]);
101102 }
102-
103- // set up the drawing
104103 Drawing drawing = new Drawing (grid );
104+
105+ // set up the window frame
105106 JFrame frame = new JFrame ("Drawing" );
106107 frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
108+ frame .setResizable (false );
107109 frame .add (drawing );
108110 frame .pack ();
109111 frame .setVisible (true );
110112
111113 // main simulation loop
114+ Toolkit toolkit = frame .getToolkit ();
112115 while (true ) {
113116
114117 // update the drawing
@@ -118,6 +121,7 @@ public static void main(String[] args) {
118121 // delay the simulation
119122 try {
120123 Thread .sleep (500 );
124+ toolkit .sync ();
121125 } catch (InterruptedException e ) {
122126 // do nothing
123127 }
You can’t perform that action at this time.
0 commit comments