/*********************
*Program by Kashid
*Created on July 2005
*********************/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Changebgcolor extends Applet implements ItemListener
{
/*<Applet code="Changebgcolor.class" height=200 width=200>
</Applet>*/
Choice ch;
Color sel;
String clr;
public void init()
{
setBackground(Color.orange);
sel=Color.yellow;
ch=new Choice();
ch.add("orange");
ch.add("green");
ch.add("yellow");
ch.add("magenta");
ch.addItemListener(this);
add(ch);
}
public void itemStateChanged(ItemEvent e)
{
clr=ch.getSelectedItem();
if(clr.equals("orange"))
sel=Color.orange;
if(clr.equals("green"))
sel=Color.green;
if(clr.equals("yellow"))
sel=Color.yellow;
if(clr.equals("magenta"))
sel=Color.magenta;
setBackground(sel);
}
}
0 comments:
Post a Comment