Color
//******************************************************************************
// project5.for.java: Applet
//
//******************************************************************************
import java.applet.*;
import java.awt.*;
public class project5 extends Applet
{
//String sText;
boolean bRed,
bGreen,
bBlue;
Button btnRed,
btnGreen,
btnBlue;
Label lblPrompt;
TextField txtData;
public project5()
{
// TODO: Add constructor code here
}
public String getAppletInfo()
{
return "Name: project5\r\n" +
"Author: \r\n" +
"Created with Microsoft Visual J++ Version 6.0";
}
public void init()
{
resize( 300, 45 );
//sText = "That's All Folks";
btnRed = new Button("Red");
btnGreen = new Button("Green");
btnBlue = new Button("Blue");
lblPrompt = new Label("Color");
txtData = new TextField ("Default Gray");
add(btnRed);
add(btnGreen);
add(btnBlue);
add(lblPrompt);
add(txtData);
// TODO: Place additional initialization code here
}
public void paint(Graphics g)
{
g.setColor ( new Color (50, 50, 50) );
g.fillRect ( 0, 0, 350, 45 );
if (bRed)
{
g.setColor ( new Color (255, 100, 100) );
g.fillRect ( 0, 0, 340, 35 );
}
if (bGreen)
{
g.setColor ( new Color (100, 255, 100) );
g.fillRect ( 0, 0, 340, 35 );
}
if (bBlue)
{
g.setColor ( new Color (100, 100, 255) );
g.fillRect ( 0, 0, 340, 35 );
}
}
public void start()
{
// TODO: Place additional applet start code here
}
public void stop()
{
}
}