Login    New User    Forgot Password    Help      

Lamp Applet

Java Tutorials

// lamp applet
/*
Color Name RGB Value
Color.white 255,255,255
Color.black 0,0,0
Color.lightGray 192,192,192
Color.gray 128,128,128
Color.darkGray 64,64,64
Color.red 255,0,0
Color.green 0,255,0
Color.blue 0,0,255
Color.yellow 255,255,0
Color.magenta 255,0,255
Color.cyan 0,255,255
Color.pink 255,175,175
Color.orange 255,200,0
*/
import java.awt.*;
public class app4 extends java.applet.Applet
{

 

public void paint(Graphics g) {

// the lamp platform
g.setColor(Color.blue);
g.fillRect(0,250,290,290);

// the base of the lamp
g.setColor(Color.green);
g.drawLine(125,250,125,160);
g.drawLine(175,250,175,160);

// the lamp shade, top and bottom edges

g.drawArc(85,157,130,50,-65,312);
g.drawArc(85,87,130,50,62,58);

// lamp shade, sides

g.drawLine(85,177,119,89);
g.drawLine(215,177,181,89);

// dots on the shade
g.setColor(Color.blue);
g.fillArc(78,120,40,40,63,-174);
g.fillOval(120,96,40,40);
g.fillArc(173,100,40,40,110,180);

}
}

Output

Output in Applet

Java Tutorials