my program works fine but i dont know why when i debug the program the shapes are coming out without me pressing the buttons
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AnAppletWithButtons extends Applet implements ActionListener
{
Button button1, button2;
int r, g , b;
Color color;
boolean drawLine = false;
public void init()
{
String parmStringRED = getParameter("red");
r = Integer.parseInt(parmStringRED);
String parmStringGREEN = getParameter("green");
g = Integer.parseInt(parmStringGREEN);
String parmStringBLUE = getParameter("blue");
b = Integer.parseInt(parmStringBLUE);
color = new Color (r,g,b);
button1 = new Button("Button 1");
add(button1);
button1.addActionListener(this);
button2 = new Button("Button 2");
add(button2);
button2.addActionListener(this);
button1.setForeground(color);
button2.setForeground(color);
button1.setBackground(Color.yellow);
button2.setBackground(Color.yellow);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == button1)
drawLine = true;
else
drawLine = false;
repaint();
}
public void paint(Graphics g)
{
super.paint(g); // for the background
if(drawLine)
g.drawLine(0, 0, 100, 100);
else
g.fillOval(20, 10, 15, 30);
}
}