Sabtu, 15 Juni 2013

Project PBO

// Project Mata Kuliah Pemograman Berbasis Objek
// Dosen:  Suryaningrum
// Disusun Oleh :
//   Handoko Karullah Hadi Putra
//   Krisna Sembiring
//   Oky Riyani
// Kelas 2IA22
// Teknik Informatika - Universitas Gunadarma

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

class contohTombol3 {
static int lebar = 300;
public static void main(String[] arg){

final JFrame jendela = new JFrame();
jendela.setTitle("Contoh Tombol 3");
jendela.setSize(lebar,lebar);
jendela.setVisible(true);
jendela.setLayout(null);

JButton tombol = new JButton();
tombol.setText("Perbesar");
tombol.setSize(100,20);
tombol.setLocation(20,10);

JButton tombol2 = new JButton();
tombol2.setText("Perkecil");
tombol2.setSize(100,20);
tombol2.setLocation(130,10);

jendela.getContentPane().add(tombol);
jendela.getContentPane().add(tombol2);

tombol.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
lebar = lebar + 10;
jendela.setSize(lebar,lebar);
}
});

tombol2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
lebar = lebar - 10;
jendela.setSize(lebar,lebar);
}
}); 

}
}

Output Program