// Header yang berfungsi untuk memanggil package
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
// pewarisan dari JFrame untuk digunakan di class Form2
public class MahfuzASD extends JFrame {
public MahfuzASD() {
// PEMBUATAN OBJEK
JPanel panel1 = new JPanel(); // pembuatan panel 1
JPanel panel2 = new JPanel(); // pembuatan panel 2
Container container = this.getContentPane(); // pembuatan container
// Membuat objek option button baru
final JRadioButton RadioButton1 = new JRadioButton("TOSHIBA");
final JRadioButton RadioButton2 = new JRadioButton("ACER");
final JRadioButton RadioButton3 = new JRadioButton("SONY VAIO");
final JRadioButton RadioButton4 = new JRadioButton("SAMSUNG");
final JRadioButton RadioButton5 = new JRadioButton("HP/COMPAQ");
final JRadioButton RadioButton6 = new JRadioButton("AXIOO");
final JRadioButton RadioButton7 = new JRadioButton("ASSUS");
final JRadioButton RadioButton8 = new JRadioButton("DELL");
final JRadioButton RadioButton9 = new JRadioButton("BENQ");
final JRadioButton RadioButton10= new JRadioButton("LENOVO");
final JRadioButton RadioButton11= new JRadioButton("ASPIRE");
final JRadioButton RadioButton12= new JRadioButton("APPLE");
// Membuat button group
ButtonGroup radioButtonGroup = new ButtonGroup();
// Membuat label untuk spesifikasi laptop
JLabel labelHARGA = new JLabel("HARGA ");
final JLabel labelPROSESOR = new JLabel("PROSESOR ");
final JLabel labelTIPE = new JLabel("TIPE ");
final JLabel labelUKURAN = new JLabel("UKURAN" );
// Membuat text field untuk spesifikasi laptop
final JTextField textHARGA = new JTextField(5);
final JTextField textPROSESOR = new JTextField(5);
final JTextField textTIPE = new JTextField(5);
final JTextField textUKURAN = new JTextField(10);
final JTextField textUKURAN1 = new JTextField(5);
final JButton cmdTampil = new JButton("Ayo Tampilkan!");
final JButton cmdHapus = new JButton("Hapus");
final JButton cmdExit = new JButton("Keluar");
// konfigurasi layout
container.setLayout(new GridLayout(1,2));
panel1.setLayout(new GridLayout(3,3,2,5));
panel2.setLayout(new GridLayout(6,3,2,5));
panel1.setBorder(BorderFactory.createTitledBorder("MERK LAPTOP"));
panel2.setBorder(BorderFactory.createTitledBorder("SPESIFIKASI"));
// menambahkan panel ke window
// panel 1 untuk merk laptop dan panel 2 untuk spesifikasi
container.add(panel1);
container.add(panel2);
// mendaftarkan radio button sebagai group merk/jenis laptop
radioButtonGroup.add(RadioButton1);
radioButtonGroup.add(RadioButton2);
radioButtonGroup.add(RadioButton3);
radioButtonGroup.add(RadioButton4);
radioButtonGroup.add(RadioButton5);
radioButtonGroup.add(RadioButton6);
radioButtonGroup.add(RadioButton7);
radioButtonGroup.add(RadioButton8);
radioButtonGroup.add(RadioButton9);
radioButtonGroup.add(RadioButton10);
radioButtonGroup.add(RadioButton11);
radioButtonGroup.add(RadioButton12);
// menambahkan objek ke dalam panel 1 (merk laptop)
panel1.add(RadioButton1);
panel1.add(RadioButton2);
panel1.add(RadioButton3);
panel1.add(RadioButton4);
panel1.add(RadioButton5);
panel1.add(RadioButton6);
panel1.add(RadioButton7);
panel1.add(RadioButton8);
panel1.add(RadioButton9);
panel1.add(RadioButton10);
panel1.add(RadioButton11);
panel1.add(RadioButton12);
// menambahkan objek ke dalam panel 2 (spesifikasi)
panel2.add(labelHARGA);
panel2.add(textHARGA);
panel2.add(labelPROSESOR);
panel2.add(textPROSESOR);
panel2.add(labelTIPE);
panel2.add(textTIPE);
panel2.add(labelUKURAN);
panel2.add(textUKURAN);
panel2.add(textUKURAN1);
panel2.add(cmdTampil);
panel2.add(cmdHapus);
panel2.add(cmdExit);
/* memberikan even handling kepada command button
untuk isi panel 1 dan panel 2
*/
cmdTampil.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
if (RadioButton1.isSelected()){
textHARGA.setText("Rp 6.000.000.00");
textPROSESOR.setText("Intel Pentium Dual Core Inside");
textTIPE.setText("Toshiba Satellite C640");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText(" Thank You Mr./Mrs. ^_^");
}
else if (RadioButton2.isSelected()){
textHARGA.setText("Rp 5.500.000.00");
textPROSESOR.setText("Intel Core i5 Inside");
textTIPE.setText("Acer 4738Z Pro");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Matur Suwun coy..!! ^_^");
}
else if (RadioButton3.isSelected()){
textHARGA.setText("Rp 8.000.000.00");
textPROSESOR.setText("Intel Core i3 Inside");
textTIPE.setText("Sony 110 Series");
textUKURAN.setText("LCD 14.1' 16:9");
textUKURAN1.setText("Lembo Ade Lenga... ^_^");
}
else if (RadioButton4.isSelected()){
textHARGA.setText("Rp 4.700.000.00");
textPROSESOR.setText("Intel Core 2 Duo Inside");
textTIPE.setText("Samsung S134LE");
textUKURAN.setText("LCD 12' 14:6");
textUKURAN1.setText("Terima Kasih ^_^");
}
else if (RadioButton5.isSelected()){
textHARGA.setText("Rp 4.700.000.00");
textPROSESOR.setText("Intel AMD Turion Inside");
textTIPE.setText("HP CQ41-208AU");
textUKURAN.setText("LCD 16' 18:11");
textUKURAN1.setText("Thank You Forever ^_^");
}
else if (RadioButton6.isSelected()){
textHARGA.setText("Rp 7.400.000.00");
textPROSESOR.setText("Intel Core 2 Duo-Centrino Inside");
textTIPE.setText("Axioo ZETTA 342 Series");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Selamat Menggunakan!! ^_^");
}
else if (RadioButton7.isSelected()){
textHARGA.setText("Rp 5.000.000.00");
textPROSESOR.setText("Intel Core i3 Inside");
textTIPE.setText("Assus P5112S");
textUKURAN.setText("LCD 12' 14:8");
textUKURAN1.setText("Terima Kasih ^_^");
}
else if (RadioButton8.isSelected()){
textHARGA.setText("Rp 8.500.000.00");
textPROSESOR.setText("Intel Core i5 Inside");
textTIPE.setText("Dell SE547 Series");
textUKURAN.setText("LCD 19' 19:11");
textUKURAN1.setText("Kami Ada Untuk Anda ^_^");
}
else if (RadioButton9.isSelected()){
textHARGA.setText("Rp 4.000.000.00");
textPROSESOR.setText("Intel AMD Turion x2 Inside");
textTIPE.setText("Benq 203 SE");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Thank You For All ^_^");
}
else if (RadioButton10.isSelected()){
textHARGA.setText("Rp 4.400.000.00");
textPROSESOR.setText("Intel Dual Core Inside");
textTIPE.setText("Lenovo 4733L");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Semoga Bermanfaat ^_^");
}
else if (RadioButton11.isSelected()){
textHARGA.setText("Rp 3.500.000.00");
textPROSESOR.setText("Intel Atom Inside");
textTIPE.setText("Aspire 4730Z");
textUKURAN.setText("LCD 10' 12:5");
textUKURAN1.setText("Insya Allah Asli! ^_^");
}
else if (RadioButton12.isSelected()){
textHARGA.setText("Rp 13.000.000.00");
textPROSESOR.setText("Intel Core i3 Inside");
textTIPE.setText("Apple M157 Pro Series");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Produk Indonesia ^_^");
}
}
});
/*cmd atau button yang berfungsi untuk menghapus atau
mengosongkan isi panel 2 (spesifikasi)
*/
cmdHapus.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
textHARGA.setText(" ");
textPROSESOR.setText(" ");
textTIPE.setText(" ");
textUKURAN.setText(" ");
}
});
cmdExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.exit(1);
}
}
);
// menampilkan window java
setTitle("DAFTAR HARGA LAPTOP PT. MAHFUZ SETIA UNTUK BULAN MEI 2011");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(100,120);
this.setSize(800,300);
this.setVisible(true);
}
public static void main(String[] args){
new MahfuzASD();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
// pewarisan dari JFrame untuk digunakan di class Form2
public class MahfuzASD extends JFrame {
public MahfuzASD() {
// PEMBUATAN OBJEK
JPanel panel1 = new JPanel(); // pembuatan panel 1
JPanel panel2 = new JPanel(); // pembuatan panel 2
Container container = this.getContentPane(); // pembuatan container
// Membuat objek option button baru
final JRadioButton RadioButton1 = new JRadioButton("TOSHIBA");
final JRadioButton RadioButton2 = new JRadioButton("ACER");
final JRadioButton RadioButton3 = new JRadioButton("SONY VAIO");
final JRadioButton RadioButton4 = new JRadioButton("SAMSUNG");
final JRadioButton RadioButton5 = new JRadioButton("HP/COMPAQ");
final JRadioButton RadioButton6 = new JRadioButton("AXIOO");
final JRadioButton RadioButton7 = new JRadioButton("ASSUS");
final JRadioButton RadioButton8 = new JRadioButton("DELL");
final JRadioButton RadioButton9 = new JRadioButton("BENQ");
final JRadioButton RadioButton10= new JRadioButton("LENOVO");
final JRadioButton RadioButton11= new JRadioButton("ASPIRE");
final JRadioButton RadioButton12= new JRadioButton("APPLE");
// Membuat button group
ButtonGroup radioButtonGroup = new ButtonGroup();
// Membuat label untuk spesifikasi laptop
JLabel labelHARGA = new JLabel("HARGA ");
final JLabel labelPROSESOR = new JLabel("PROSESOR ");
final JLabel labelTIPE = new JLabel("TIPE ");
final JLabel labelUKURAN = new JLabel("UKURAN" );
// Membuat text field untuk spesifikasi laptop
final JTextField textHARGA = new JTextField(5);
final JTextField textPROSESOR = new JTextField(5);
final JTextField textTIPE = new JTextField(5);
final JTextField textUKURAN = new JTextField(10);
final JTextField textUKURAN1 = new JTextField(5);
final JButton cmdTampil = new JButton("Ayo Tampilkan!");
final JButton cmdHapus = new JButton("Hapus");
final JButton cmdExit = new JButton("Keluar");
// konfigurasi layout
container.setLayout(new GridLayout(1,2));
panel1.setLayout(new GridLayout(3,3,2,5));
panel2.setLayout(new GridLayout(6,3,2,5));
panel1.setBorder(BorderFactory.createTitledBorder("MERK LAPTOP"));
panel2.setBorder(BorderFactory.createTitledBorder("SPESIFIKASI"));
// menambahkan panel ke window
// panel 1 untuk merk laptop dan panel 2 untuk spesifikasi
container.add(panel1);
container.add(panel2);
// mendaftarkan radio button sebagai group merk/jenis laptop
radioButtonGroup.add(RadioButton1);
radioButtonGroup.add(RadioButton2);
radioButtonGroup.add(RadioButton3);
radioButtonGroup.add(RadioButton4);
radioButtonGroup.add(RadioButton5);
radioButtonGroup.add(RadioButton6);
radioButtonGroup.add(RadioButton7);
radioButtonGroup.add(RadioButton8);
radioButtonGroup.add(RadioButton9);
radioButtonGroup.add(RadioButton10);
radioButtonGroup.add(RadioButton11);
radioButtonGroup.add(RadioButton12);
// menambahkan objek ke dalam panel 1 (merk laptop)
panel1.add(RadioButton1);
panel1.add(RadioButton2);
panel1.add(RadioButton3);
panel1.add(RadioButton4);
panel1.add(RadioButton5);
panel1.add(RadioButton6);
panel1.add(RadioButton7);
panel1.add(RadioButton8);
panel1.add(RadioButton9);
panel1.add(RadioButton10);
panel1.add(RadioButton11);
panel1.add(RadioButton12);
// menambahkan objek ke dalam panel 2 (spesifikasi)
panel2.add(labelHARGA);
panel2.add(textHARGA);
panel2.add(labelPROSESOR);
panel2.add(textPROSESOR);
panel2.add(labelTIPE);
panel2.add(textTIPE);
panel2.add(labelUKURAN);
panel2.add(textUKURAN);
panel2.add(textUKURAN1);
panel2.add(cmdTampil);
panel2.add(cmdHapus);
panel2.add(cmdExit);
/* memberikan even handling kepada command button
untuk isi panel 1 dan panel 2
*/
cmdTampil.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
if (RadioButton1.isSelected()){
textHARGA.setText("Rp 6.000.000.00");
textPROSESOR.setText("Intel Pentium Dual Core Inside");
textTIPE.setText("Toshiba Satellite C640");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText(" Thank You Mr./Mrs. ^_^");
}
else if (RadioButton2.isSelected()){
textHARGA.setText("Rp 5.500.000.00");
textPROSESOR.setText("Intel Core i5 Inside");
textTIPE.setText("Acer 4738Z Pro");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Matur Suwun coy..!! ^_^");
}
else if (RadioButton3.isSelected()){
textHARGA.setText("Rp 8.000.000.00");
textPROSESOR.setText("Intel Core i3 Inside");
textTIPE.setText("Sony 110 Series");
textUKURAN.setText("LCD 14.1' 16:9");
textUKURAN1.setText("Lembo Ade Lenga... ^_^");
}
else if (RadioButton4.isSelected()){
textHARGA.setText("Rp 4.700.000.00");
textPROSESOR.setText("Intel Core 2 Duo Inside");
textTIPE.setText("Samsung S134LE");
textUKURAN.setText("LCD 12' 14:6");
textUKURAN1.setText("Terima Kasih ^_^");
}
else if (RadioButton5.isSelected()){
textHARGA.setText("Rp 4.700.000.00");
textPROSESOR.setText("Intel AMD Turion Inside");
textTIPE.setText("HP CQ41-208AU");
textUKURAN.setText("LCD 16' 18:11");
textUKURAN1.setText("Thank You Forever ^_^");
}
else if (RadioButton6.isSelected()){
textHARGA.setText("Rp 7.400.000.00");
textPROSESOR.setText("Intel Core 2 Duo-Centrino Inside");
textTIPE.setText("Axioo ZETTA 342 Series");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Selamat Menggunakan!! ^_^");
}
else if (RadioButton7.isSelected()){
textHARGA.setText("Rp 5.000.000.00");
textPROSESOR.setText("Intel Core i3 Inside");
textTIPE.setText("Assus P5112S");
textUKURAN.setText("LCD 12' 14:8");
textUKURAN1.setText("Terima Kasih ^_^");
}
else if (RadioButton8.isSelected()){
textHARGA.setText("Rp 8.500.000.00");
textPROSESOR.setText("Intel Core i5 Inside");
textTIPE.setText("Dell SE547 Series");
textUKURAN.setText("LCD 19' 19:11");
textUKURAN1.setText("Kami Ada Untuk Anda ^_^");
}
else if (RadioButton9.isSelected()){
textHARGA.setText("Rp 4.000.000.00");
textPROSESOR.setText("Intel AMD Turion x2 Inside");
textTIPE.setText("Benq 203 SE");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Thank You For All ^_^");
}
else if (RadioButton10.isSelected()){
textHARGA.setText("Rp 4.400.000.00");
textPROSESOR.setText("Intel Dual Core Inside");
textTIPE.setText("Lenovo 4733L");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Semoga Bermanfaat ^_^");
}
else if (RadioButton11.isSelected()){
textHARGA.setText("Rp 3.500.000.00");
textPROSESOR.setText("Intel Atom Inside");
textTIPE.setText("Aspire 4730Z");
textUKURAN.setText("LCD 10' 12:5");
textUKURAN1.setText("Insya Allah Asli! ^_^");
}
else if (RadioButton12.isSelected()){
textHARGA.setText("Rp 13.000.000.00");
textPROSESOR.setText("Intel Core i3 Inside");
textTIPE.setText("Apple M157 Pro Series");
textUKURAN.setText("LCD 14' 16:9");
textUKURAN1.setText("Produk Indonesia ^_^");
}
}
});
/*cmd atau button yang berfungsi untuk menghapus atau
mengosongkan isi panel 2 (spesifikasi)
*/
cmdHapus.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
textHARGA.setText(" ");
textPROSESOR.setText(" ");
textTIPE.setText(" ");
textUKURAN.setText(" ");
}
});
cmdExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.exit(1);
}
}
);
// menampilkan window java
setTitle("DAFTAR HARGA LAPTOP PT. MAHFUZ SETIA UNTUK BULAN MEI 2011");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(100,120);
this.setSize(800,300);
this.setVisible(true);
}
public static void main(String[] args){
new MahfuzASD();
}
}
0 komentar:
Posting Komentar