Tugas ke 3 Grafika Komputer

Program Mendesain Bola sederhana dan
sebelumnya aku minta maaf karena masih banyak kekurangan aku.

Ini lisning programnya :



package sepedesederhana;
import java.awt.*;
import java.awt.event.*;
public class SepedeSederhana extends Frame implements ActionListener{
    int x = 100;
    int y = 100;
public static void main(String[] args) {
    Frame frame = new SepedeSederhana();
    frame.setSize(640, 480);
    frame.setVisible(true);
}
public SepedeSederhana() {
setTitle("AWT Demo");
// create menu
    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menu = new Menu("File");
    mb.add(menu);
    MenuItem mi = new MenuItem("Exit");
  // end program when window is closed
    WindowListener l = new WindowAdapter()  {
    @Override
    public void windowClosing(WindowEvent ev) {
    System.exit(0);
    }
    };
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent ev) {
    x = ev.getX();
    y = ev.getY();
    repaint();
}
};
addMouseListener(mouseListener);
}
    @Override
    public void paint(Graphics g) {
g.setColor(Color.black);
g.fillOval(100, 330, 20, 20);
g.fillOval(510, 330, 20, 20);
g.setColor(Color.black);
g.drawOval(10,240,  200, 200);
g.setColor(Color.black);
g.drawOval(420,240,  200, 200);
g.setColor(Color.black);
g.fillOval(330, 330, 30,30);
g.fillOval(330, 330, 200,10);
 g.setColor(Color.BLACK);
 g.fillRect(150, 150,8, 200);
    
     
g.drawLine(40, 130, 500, 200);
g.drawArc(380, 360, 90, 50, 180, 180);
g.drawRect(110, 240, 2, 200); //g.drawRect(x, y, WIDTH, WIDTH)
g.drawRect(115, 240, 0, 200); //g.drawRect(x, y, WIDTH, WIDTH)
g.drawRect(150, 250, 0, 10); //g.drawRect(x, y, WIDTH, WIDTH)
g.drawRect(150, 150, 0, 100); //g.drawRect(x, y, WIDTH, WIDTH)
}
    @Override
    public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
    private void addActionListener(SepedeSederhana aThis) {
        throw new UnsupportedOperationException("Not supported yet.");
        //To change body of generated methods, choose Tools | Templates.
    }

Berikut hasil Outputnya ..........

Komentar

Postingan populer dari blog ini

Lirik Lagu Seribu Kota / Walau Sekejap - Ari Wibowo

cara kerja memori

KRITIK MENGENAI TEKNOLOGI MAJU