- public void paint(Graphics g) {
- synchronized (image) {
- g.drawImage(image, 0, 0, null);
- }
+ /* PRIVATE STUFF FOLLOWS */
+
+ private final String title; // window's title
+ private JFrame frame; // the frame (window)
+ private DWPanel panel; // the panel showing the image
+ private BufferedImage image; // the image we draw into
+ private Graphics2D graphics; // graphics associated with image
+ private Color bgColor; // background color, for clearGraph()
+
+ // To be run on the Event Dispatching Thread
+ void createGUI() {
+ panel = new DWPanel(this);
+
+ frame = new JFrame(title);
+ frame.add(panel);
+ frame.pack();
+ frame.setResizable(false);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.addKeyListener(panel);
+ frame.setLocationByPlatform(true);
+ frame.setVisible(true);