hy,.,......☻☻
nama saya Apsyalom Magang, Kali ini saya akan Coba memosting tugas dari Dosen saya mudah_mudahan bermanfaaat buat Sobb Smua yaNg nemu'in Blog ini ...........mohOn maaf jika ada Kesalahan ataupun tidak sesuai dengan keinginan sobb smua,.,.,.maklummmm daLam taHappp beLajaRrrrrrrr,,,,,,,x,ixixixixixixixixixixi
package penggunaanawt;
import java.awt.*;
import java.awt.event.*;
public class AWTDemo extends Frame implements ActionListener{
int x = 50;
int y = 100;
public static void main(String[] args) {
Frame frame = new AWTDemo();
frame.setSize(640, 480);
frame.setVisible(true);
}
public AWTDemo() {
setTitle("AWT Demo");
// 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) {
int xasalA=150; int yasalA=100;
int xasalB=100; int yasalB=250;
int xasalC=200; int yasalC=250;
int sudut=45;
g.setColor(Color.green);
g.drawLine(x, y, 400,100);
g.drawLine(400, 100, 400,300);
}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}
Tidak ada komentar:
Posting Komentar