1

So the only differences between my code and the narrator's in the video are the interfaces (I have Netbeans, he uses Eclipse), and one line of code he said was unnecessary. Watch it here, if that helps. Thank you

    package pixelgen;
    import java.awt.Canvas;
    import java.awt.Dimension;
    import javax.swing.JFrame;

    public class PixelGen extends Canvas implements Runnable {

        public static final int HIGH = 120;
        public static final int WIDE = 120;
        public static final int SCALE = 3;

        public static final String NAME = "PixelGen";

        @Override 
        public void run(){
         }

       public static void main(String[] args) {
            PixelGen game = new PixelGen();
            game.setPreferredSize(new Dimension(WIDE * SCALE, HIGH * SCALE));
            game.setMaximumSize(new Dimension(WIDE * SCALE, HIGH * SCALE));
            game.setMinimumSize(new Dimension(WIDE * SCALE, HIGH * SCALE));

            JFrame frame = new JFrame(NAME);

            frame.add(game);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            frame.pack();
            frame.setVisible(true);
            frame.setResizable(true);


        }
    }
iKlsR
  • 2,642
  • 6
  • 27
  • 45
  • 1
    what is the line, and what happens when you put it in? – mcalex Jun 12 '13 at 05:14
  • 5
    1) Why AWT `Canvas` rather than Swing? See this answer on [Swing extras over AWT](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon using AWT components. 2) Create and show GUIs on the EDT (Event Dispatch Thread). See [Concurrency in Swing](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/) for more details. – Andrew Thompson Jun 12 '13 at 05:14
  • 3
    And the problem is? It runs fine for me, but I would take Andrew's advice first – MadProgrammer Jun 12 '13 at 05:18

0 Answers0