package Nuraini;
import java.awt.*;
import java.awt.event.*;
public class Nuraini extends Frame implements ActionListener{
    int x = 100;
    int y = 100;
public static void main(String[] args) {
    Frame frame = new Nuraini();
    frame.setSize(640, 480);
    frame.setVisible(true);
}
public Nuraini() {
setTitle("Nuraini");
// create menu
    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menu = new Menu("File");
    mb.add(menu);
    MenuItem mi = new MenuItem("Exit");
    mi.addActionListener(this);
    menu.add(mi);
// end program when window is closed
    WindowListener l = new WindowAdapter()  {
    public void windowClosing(WindowEvent ev) {
    System.exit(0);
    }
    };
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
    x = ev.getX();
    y = ev.getY();
    repaint();
}
};
addMouseListener(mouseListener);
}
public void paint(Graphics g) {
setBackground (Color.PINK);
        //kepala
g.setColor(Color.RED);
g.drawOval(320,240,  200, 200);
// mata
g.setColor(Color.black);
g.fillOval(360, 310, 50, 20);
g.fillOval(440, 310, 50, 20);
// mulut
g.setColor(Color.black);
g.drawArc(380, 360, 90, 50, 180, 180);
g.drawArc(380, 366, 90, 50, 180, 180);
//alis mata
g.setColor(Color.RED);
g.drawArc(360, 290, 50, 20, -180, -180);
g.drawArc(440, 290, 50, 20, -180, -180);
// bola mata
g.setColor(Color.white);
g.fillOval(379, 321, 10, 10);
g.fillOval(457, 321, 10, 10);
//hidung
g.setColor(Color.GREEN);
g.fillOval(410, 350, 30, 30);
//telinga
g.setColor(Color.YELLOW);
g.fillOval(300, 310, 20, 60);
g.fillOval(520, 310, 20, 60);
}
public void actionPerformed(ActionEvent ev) {
  
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}

MEMBUAT ORANG.AWT
Langganan:
Posting Komentar (Atom)


 
0 komentar:
Posting Komentar