1. Creating Smiley Face
This tutorial, "Draw Smiley Face Java Nested Panels", gives command over graphics to a novice. Fill ovals and arc are arranged in such way it looks smiley face. For beautification, a background color of pink (predefined color) is given.
Example on Smiley Face
import java.awt.*;
public class SmileyFace extends Frame
{
public SmileyFace()
{
setTitle("Smiley Face");
setSize(300, 300);
setVisible(true);
}
public void paint(Graphics g)
{
g.setColor(Color.pink);
g.fillOval(10,40,250,250); // pinky round face
g.setColor(Color.black); // lines will be in black
g.fillOval(75, 80, 32, 32); // left eye
g.fillOval(180, 80, 32, 32); // right eye
g.drawArc(100,110,110,110,180,180); // mouth
}
public static void main(String args[])
{
new SmileyFace();
}
}

Just change the mouth arc as follows to see a sad face.
g.drawArc(110,150,100,100,0,180);
Pages: 1 2