import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class Digit extends JApplet implements ItemListener, ActionListener
{
int digit, length;
String userIn;
ButtonGroup colourGroup;
JRadioButton redRB, blueRB, magentaRB, blackRB, greenRB, cyanRB, yellowRB, pinkRB;
Color currentColour = Color.black;
public void init()
{
Container c = getContentPane();
c.setLayout(null);
redRB = new JRadioButton("Red");
blueRB = new JRadioButton("Blue");
magentaRB = new JRadioButton("Magenta");
blackRB = new JRadioButton("Black");
greenRB = new JRadioButton("Green");
cyanRB = new JRadioButton("Cyan");
yellowRB = new JRadioButton("Yellow");
pinkRB = new JRadioButton("Pink");
redRB.setSize(100, 20);
blueRB.setSize(100, 20);
magentaRB.setSize(100, 20);
blackRB.setSize(100, 20);
greenRB.setSize(100, 20);
cyanRB.setSize(100, 20);
yellowRB.setSize(100, 20);
pinkRB.setSize(100, 20);
redRB.setLocation(20, 250);
blueRB.setLocation(20, 270);
magentaRB.setLocation(20, 290);
blackRB.setLocation(20, 310);
greenRB.setLocation(130, 250);
cyanRB.setLocation(130, 270);
yellowRB.setLocation(130, 290);
pinkRB.setLocation(130, 310);
redRB.addItemListener(this);
blueRB.addItemListener(this);
magentaRB.addItemListener(this);
blackRB.addItemListener(this);
greenRB.addItemListener(this);
cyanRB.addItemListener(this);
yellowRB.addItemListener(this);
pinkRB.addItemListener(this);
c.add(redRB);
c.add(blueRB);
c.add(magentaRB);
c.add(blackRB);
c.add(greenRB);
c.add(cyanRB);
c.add(yellowRB);
c.add(pinkRB);
colourGroup = new ButtonGroup();
colourGroup.add(redRB);
colourGroup.add(blueRB);
colourGroup.add(magentaRB);
colourGroup.add(blackRB);
colourGroup.add(greenRB);
colourGroup.add(cyanRB);
colourGroup.add(yellowRB);
colourGroup.add(pinkRB);
}
public void paint(Graphics g)
{
g.setColor(Color.black);
g.drawString("hello"[LEFT][/LEFT]);
}
public void itemStateChanged(ItemEvent e)
{
if(e.getSource() == redRB)
currentColour = Color.red;
else if(e.getSource() == blueRB)
currentColour = Color.blue;
else if(e.getSource() == magentaRB)
currentColour = Color.magenta;
else if(e.getSource() == blackRB)
currentColour = Color.black;
else if(e.getSource() == greenRB)
currentColour = Color.green;
else if(e.getSource() == cyanRB)
currentColour = Color.cyan;
else if(e.getSource() == yellowRB)
currentColour = Color.yellow;
else if(e.getSource() == pinkRB)
currentColour = Color.pink;
repaint();
}
}