I am working on a slot machine in Java and so far I created a button that will randomly generate two pictures. My code compiles but when I run it, all the stuff I put in the paint method does not show up. Is there anything I am missing? Thanks for your help and here is some of my code.
public void paint(Graphics g) {
super.paintComponents(g);
g.drawString("Int 1 is" + int1,30,30);
g.drawString("Int 2 is" + int2,30,80);
switch (int1) {
case 0:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img, 300, 500, this);
break;
case 1:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img2,300,500,this);
break;
case 2:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img3,300,500,this);
break;
case 3:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img4,300,500,this);
break;
case 4:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img5,300,500,this);
break;
case 5:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img6,300,500,this);
break;
case 6:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img7,300,500,this);
break;
case 7:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img8,300,500,this);
break;
case 8:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img9,300,500,this);
break;
case 9:
g.setColor(Color.white);
g.fillRect(300,300,300,500);
g.drawImage(img10,300,500,this);
break;
}
switch (int2) {
case 0:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img, 800, 500, this);
break;
case 1:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img2,800,500,this);
break;
case 2:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img3,800,500,this);
break;
case 3:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img4,800,500,this);
break;
case 4:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img5,800,500,this);
break;
case 5:
\ g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img6,800,500,this);
break;
case 6:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img7,800,500,this);
break;
case 7:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img8,800,500,this);
break;
case 8:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img9,800,500,this);
break;
case 9:
g.setColor(Color.white);
g.fillRect(300,300,800,500);
g.drawImage(img10,800,500,this);
break;
}
this.setVisible(true);
}