Tantastic
Member
Registered: 23rd Jan 07
User status: Offline
|
very simple piece of code below. basically as it stands the check boxes are just placed in the applet.
how do i set the location of it to say 100 across and 500 down, thanks
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class BackgroundColor extends Applet implements ItemListener
{
private CheckboxGroup c;
private Checkbox red, orange, yellow;
public void init()
{
c = new CheckboxGroup();
red = new Checkbox("Red", c, false);
add(red);
red.addItemListener(this);
orange = new Checkbox("Orange", c, true);
add(orange);
orange.addItemListener(this);
yellow = new Checkbox("Yellow", c, false);
add(yellow);
yellow.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
if(e.getSource() == red)
setBackground(Color.RED);
if(e.getSource() == orange)
setBackground(Color.ORANGE);
if(e.getSource() == yellow)
setBackground(Color.YELLOW);
}
}
|