Dear all,
I need to pass my homework tomorrow, but i spent 2 more hrs still cannt complete
it. please help.
I need to do a class that just two checkbox in the applet, one is circle,
one is rectangle. when user click the circle, it draw circle, when the user
click rectangle, it draws rectangle. If user unclick, the circle or rectangle
should disappear.
Here is my coding, please help.
***********************************************
import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.* ;

public class DrawObject extends JApplet implements ItemListener
{
public boolean lCir = false, lRect = false;
public JPanel chkPanel = new JPanel();
JCheckBox chkCir = new JCheckBox("Draw CIRCLE");
JCheckBox chkRect = new JCheckBox("Draw RECTANGEL");

public void init()
{
chkPanel.setLayout(new FlowLayout());
chkCir.addItemListener(this);
chkPanel.add(chkCir);
chkRect.addItemListener(this);
chkPanel.add(chkRect);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(chkPanel);
setSize(400,400);
}

public void itemStateChanged(ItemEvent e)
{
lCir = chkCir.isSelected();
lRect = chkRect.isSelected();
repaint();
}

public void paint(Graphics s)
{
super.paint(s);
if (lCir = true)
s.fillOval(100,100,50,50);
if (lRect = true)
s.fillRect(200,200,40,40);
}
}
****************************************************************
<HTML>
<APPLET CODE = "DrawObject.class" width = 400 height = 400>
</APPLET>
</HTML>
****************************************************************
I dont know why the first time it draw circle and rectangle even i set
the two boolean to false.
I dont know why i click the checkbox , it doesnt do anything.

Thank a lot

Toms