Rabu, 28 November 2012

Contoh Listing Sederhana Kombinasi Warna Smile Berkedip Menggunakan Aplikasi netbeans 7.0.1

package pertemuanvi;

import java.awt.*;
import java.awt.event.*;
public class PertemuanVI extends Frame implements ActionListener{
    int x = 100;
    int y = 100;
public static void main(String[] args) {
    Frame frame = new PertemuanVI();
    frame.setSize(640, 480);
    frame.setVisible(true);
}
public PertemuanVI() {
setTitle("Pertemuan VI");
// 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) {

g.drawOval(120,140,200,200);
int jumlah=1;
while (jumlah <=5){
    g.drawArc(180,260,90,60,180,180);
    int jumlah2=1;
    while (jumlah2<=1000000000){
        jumlah2++;
    }
    jumlah++;

g.drawArc(160,190,50,20,-180,-180);
g.drawArc(240,190,50,20,-180,-180);
g.drawArc(180,260,90,60,180,180);
g.setColor(Color.blue);
g.fillOval(240,210,50,20);
g.fillOval(160,210,50,20);
}
}

public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}

Berikut hasil outputnya :




sedikit penjelasan :
jika ingin merubah/mengkombinasikan warna cukup blogger mania ketik g.drawfill, g.drawrect atau apapun terus di bawah listingnya ketik setColor (blue) atau bisa lainnya. Cuma itu yang bisa saya bagikan. Thanks.
»»  READMORE...

Contoh Listing Sederhana Kombinasi Warna menggunakan aplikasi netbeans 7.0.1

package penggunaanawt;

import java.awt.*;
import java.awt.event.*;
public class AWTDemo extends Frame implements ActionListener{
    int x = 100;
    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) {

g.drawLine(580, 100 , 100, 100);
g.drawLine(100, 100 , 100, 350);
g.drawLine(400, 350, 400 , 100);
g.drawLine(100,350, 700 , 350);
g.drawLine(700, 250 , 700, 350);
g.drawLine(700, 250 , 640, 250);
g.drawLine(640, 250 , 580, 100);
g.setColor(Color.orange);
g.drawString("OPELET", 150,250);  
g.setColor(Color.red);
g.fillRect(150,150,50,50);
g.fillRect(450,150,50,50);
g.fillRect(270,150,50,50);
g.setColor(Color.blue);
g.fillOval(200,300,100,100);
g.fillOval(500,300,100,100);



}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}

Berikut hasil outputnya :

»»  READMORE...

Kamis, 15 November 2012

Contoh Listing Program Berbaris Sederhana

Tugas 3 :
Contoh Listingnya :

package penggunaanawt;

import java.awt.*;
import java.awt.event.*;
public class AWTDemo extends Frame implements ActionListener{
    int x = 100;
    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 i=80;
while (i<=100){
int j=100;
while (j<=200){
   
g.drawOval(i, j, 10, 15);

j=j+30;}
i=i+20;
}
}

public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}

Berikut hasil outputnya :
 
»»  READMORE...

Minggu, 11 November 2012

Contoh Listing Program Mobil Sederhana



Tugas 2 Grafika Komputer (kombinsi garis dan lingkaran)

Listing Program : 

package penggunaanawt;
import java.awt.*;
import java.awt.event.*;
public class AWTDemo extends Frame implements ActionListener{
    int x = 100;
    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) {
g.drawLine(100, 150, 400, 150);
g.drawLine(400, 150, 400, 100);
g.drawLine(400, 100 , 100, 100);
g.drawLine(100, 100 , 100, 150);
g.drawOval(100, 100, 100, 100);
g.drawOval(300, 100, 100, 100);

}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}

Berikut hasil outputnya ketika di jalankan :
 silahkan di komen.
»»  READMORE...