title: draw or paint a 2D array in Java
body: <p>I am a beginner in java and appologies for any wrong terminology.</p>
  
  <p>I am trying to create a simple 2D game just to learn more about how java works.</p>
  
  <p>For now what I would want to know is how I would go about using a 2D array and drawing it. And maybe add a simple icon(player) you can move around with the arrowkeys.</p>
  
  <p>Currently I have the following classes Keybarricade: </p>
  
  <pre><code>public class Keybarricade{
  
  public static void main(String[] args)
  {
      JFrame obj = new JFrame();
      Playingfield playingfield = new Playingfield();
  
      obj.setBounds(0, 0, 900, 900);
      obj.setBackground(Color.GRAY);
      obj.setResizable(false);
      obj.setVisible(true);
      obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      obj.add(playingfield);
  }
  </code></pre>
  
  <p>and playingfield:</p>
  
  <pre><code>public class Playingfield extends JPanel{
  private ImageIcon playerIcon;
  private int [][] playinggrid = new int[10][10];
  private int [] playerX = new int[10];
  private int [] playerY = new int[10];
  
  public Playingfield()
  {
  
  }
  
  public void paint (Graphics g)
  {
      //draw border for playingfield
      g.setColor(Color.white);
      g.drawRect(10, 10, 876, 646);
  
      //draw background for the playingfield
      g.setColor(Color.LIGHT_GRAY);
      g.fillRect(11, 11, 875, 645);
  
      //draw player imageicon
      playerIcon = new ImageIcon("src/images/playerIcon.png");
      playerIcon.paintIcon(this, g, playerX[1], playerY[1] );
  
  }
  </code></pre>
  
  <p>this gives the following window:<a href="https://i.stack.imgur.com/RCH0f.png" rel="nofollow noreferrer">window I have right now</a></p>
  
  <p>What I would want is to use the 2D array to draw/paint a 10x10 grid, something like this: <a href="https://i.stack.imgur.com/QWQHk.png" rel="nofollow noreferrer">window I would like</a></p>
  
  <p>But sadly I couldnt find a way to do this or I did but didnt understand it.
  If someone could point me in the right dirrection that would be awsome!</p>
  
  <p>thanks in advance.</p>