title: Can't get tiles to display
body: <p>I am following a series of tutorials for Java game development tutorials. I already have a basic knowledge of Java, from thenewboston, if that helps. Anyway, I was stuck on this tutorial: <a href="http://www.youtube.com/watch?v=hN1v1ZhITDc&amp;feature=c4-overview-vl&amp;list=PL54DB126285ED0420" rel="nofollow">http://www.youtube.com/watch?v=hN1v1ZhITDc&amp;feature=c4-overview-vl&amp;list=PL54DB126285ED0420</a> The program I am creating for this tutorial is sort of like a 2D Minecraft, and at this point, the program should display a window with several tiles of dirt, stone, and sky in specific order. When I run it, it just displays a blank JFrame and I get these errors: </p>
  
  <pre><code>at mineGameMain.World.draw(World.java:80)
  at mineGameMain.GamePanel.draw(GamePanel.java:91)
  at mineGameMain.GamePanel.gameRender(GamePanel.java:85)
  at mineGameMain.GamePanel.run(GamePanel.java:51)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>I have three classes, Main:</p>
  
  <pre><code>package mineGameMain;
  
  import javax.swing.JFrame;
  
  public class Main extends JFrame{
  
      GamePanel gp;
  
      public Main(){
  
          gp = new GamePanel();
          setSize(500, 400);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setVisible(true);
          setResizable(false);
          add(gp);
  
      }
  
      public static void main(String[] args){
          Main m = new Main();
  
      }
  
  }
  </code></pre>
  
  <p>GamePanel:</p>
  
  <pre><code>    package mineGameMain;
  
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
  
      public class GamePanel extends JPanel implements Runnable{
  
          //Double Buffering
          private Image dbImage;
          private Graphics dbg;
          //JPanel variables
          static final int GWIDTH = 500, GHEIGHT = 400;
          static final Dimension gameDim = new Dimension(GWIDTH, GHEIGHT);
          //Game Variables
          private Thread game;
          private volatile boolean running = false;
  
          //Game Objects
          World world;
  
          public GamePanel(){
  
              world = new World();
              setPreferredSize(gameDim);
              setBackground(Color.WHITE);
              setFocusable(true);
              requestFocus();
              //Handle all key inputs
              addKeyListener(new KeyAdapter(){
  
                  public void keyPressed(KeyEvent e){
  
                  }
                  public void keyReleased(KeyEvent e){
  
                  }
                  public void Typed(KeyEvent e){
  
                  }           
  
              });
  
          }
  
  
          public void run(){
              while(running){
  
                  gameUpdate();
                  gameRender();
                  paintScreen();
  
              }
  
          }
  
          private void gameUpdate(){
              if(running &amp;&amp; game != null){
                  //Update game state
  
  
              }
  
          }
  
          private void gameRender(){
              if(dbImage == null){
  
                  dbImage = createImage(GWIDTH, GHEIGHT);
                  if(dbImage == null){
  
                      System.err.println("dbImage IS STILL NULL SO SHUTUPBEQUIET!");
                      return;
                  }else{
                      dbg = dbImage.getGraphics();
  
                  }
  
              }
              //Clear the screen
              dbg.setColor(Color.WHITE);
              dbg.fillRect(0, 0, GWIDTH, GHEIGHT);
              //draw Game Methods
              draw(dbg);
          }
  
          /*Draw all game content in this method*/
          private void draw(Graphics g) {
  
              world.draw(g);
  
          }
  
          private void paintScreen(){
              Graphics g;
              try{
                  g = this.getGraphics();
                  if(dbImage != null &amp;&amp; g != null){
  
                      g.drawImage(dbImage, 0, 0, null);
  
                  }
  
                  Toolkit.getDefaultToolkit().sync();
  
              }catch(Exception e){
  
                  System.err.println(e);
  
              }
  
  
          }
  
  
          public void addNotify(){
  
              super.addNotify();
              startGame();
  
          }
  
          private void startGame(){
  
              if(game == null || !running){
                  game = new Thread(this);
                  game.start();
                  running = true;
  
              }
  
          }
  
          public void stopGame(){
              if(running){
                  running = false;
  
              }
          }
  
          private void log(String s){
  
              System.out.println(s);
  
          }
      }
  </code></pre>
  
  <p>And finally, World:</p>
  
  <pre><code>package mineGameMain;
  
  import java.awt.Image;
  import java.awt.*;
  
  import javax.swing.ImageIcon;
  
  public class World {
  
      private Rectangle[] blocks;
      private Image[] blockImg;
      private final int arrayNum = 500;
      //Block images
      private Image BLOCK_DIRT_TOP, BLOCK_DIRT, BLOCK_STONE, BLOCK_SKY;
  
      private int x, y;
  
      public World(){
  
          BLOCK_DIRT_TOP = new ImageIcon("/MineGame/src/mineGameMain/Tile_Grass.png").getImage();
          BLOCK_DIRT = new ImageIcon("/MineGame/src/mineGameMain/Tile_Dirt.png").getImage();
          BLOCK_STONE = new ImageIcon("/MineGame/src/mineGameMain/Tile_Stone.png").getImage();
          BLOCK_STONE = new ImageIcon("/MineGame/src/mineGameMain/Tile_Sky.png").getImage();
          blocks = new Rectangle[500];
          blockImg = new Image[500];
  
          loadArrays();
  
      }
  
      private void loadArrays(){
  
          for(int i = 0; i &lt; arrayNum; i++){
  
              if(x &gt;= 500){
  
                  x = 0;
                  y += 20;
  
              }
  
              if( i &gt;= 0 &amp;&amp; i &lt; 100){
  
                  blockImg[i] = BLOCK_SKY;
                  blocks[i] = new Rectangle(x, y, 20, 20);
  
              }
  
              if( i &gt;= 100 &amp;&amp; i &lt; 120){
  
                  blockImg[i] = BLOCK_DIRT_TOP;
                  blocks[i] = new Rectangle(x, y, 20, 20);
  
              }
  
              if( i &gt;= 125 &amp;&amp; i &lt; 220){
  
                  blockImg[i] = BLOCK_DIRT;
                  blocks[i] = new Rectangle(x, y, 20, 20);
  
              }
  
              if( i &gt;= 225 &amp;&amp; i &lt; 500){
  
                  blockImg[i] = BLOCK_STONE;
                  blocks[i] = new Rectangle(x, y, 20, 20);
  
              }
  
              x += 20;
  
          }
  
      }
  
      public void draw(Graphics g){
  
          for(int i = 0; i &lt; arrayNum; i++){
  
              g.drawImage(blockImg[i], blocks[i].x, blocks[i].y, null);
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>Thank you for your time. If I did something wrong by posting this or if I left out any details please let me know.</p>