You Can run this program ... but , i have a problems in understanding some of the codes in Graphics class .. I don't blame anyone for this but this is a part of a lab exercise .. i need to make my snowman wave his (g.drawline) hands . using a button.. or if you can provide another way .. please do .. i'll appreciate it.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class SnowMan extends Applet implements ActionListener
{
Button button1 = new Button ("Wave!");
public void init()
{
setLayout(new BorderLayout());
add(button1, BorderLayout.NORTH);
button1.addActionListener(this);
}
public void paint(Graphics g)
{
g.fillRoundRect(240,100,10,10,10,10);
g.fillRoundRect(264,100,10,10,10,10);
/**
*eyes
*/
g.fillRoundRect(248,180,10,10,10,10);
g.fillRoundRect(248,210,10,10,10,10);
g.fillRoundRect(248,240,10,10,10,10);
g.fillRoundRect(248,270,10,10,10,10);
g.drawArc(232,65,50,70,245,50);
/**
*mouth
*/
g.drawLine(200,169, 150, 125);
g.drawLine(165,139, 145, 139);
g.drawLine(165,139, 160, 120);
/**
*
*right hands
*/
g.drawLine(300,169, 350, 125);
g.drawLine(333,139, 338, 120);
g.drawLine(333,139, 355, 138);
g.drawRoundRect(219,74,75,75,75,75);
g.setXORMode(Color.red);
g.fillRoundRect(175,148,150,150,150,150);
g.setPaintMode();
}
public void actionPerformed (ActionEvent e)
{
Object source = e.getSource();
if (button1 == source)
{
}
}
}