dimanche 17 septembre 2017

If statement not drawing to the JFrame

I made an int: int decone = 1 and then made an if statement:

  if(decone == 1) {
      g.setColor(new Color(185, 122, 87));
      g.fillRect(50, 50, 50, 100);
      g.setColor(Color.WHITE);
      g.drawString("52", 60, 60);
   }

but it won't print anything.
My whole JFrame Class is here, not the part that I named it though:

class Block extends JComponent {
  public void paintComponent(Graphics g){
    Graphics2D g2 = (Graphics2D) g;

    int decone = rn.nextInt(10);
    int dectwo = rn.nextInt(10) + 10;
    int decthree = rn.nextInt(10) + 20;
    if(decone == 1) {
      g.setColor(new Color(185, 122, 87));
      g.fillRect(50, 50, 50, 100);
      g.setColor(Color.WHITE);
      g.drawString("52", 60, 60);
    }
  }
}

Aucun commentaire:

Enregistrer un commentaire