import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Onderdil extends JFrame implements ActionListener
{
JLabel lb100 = new JLabel("PENJUALAN ONDERDIL MOBIL");
JLabel lb1 = new JLabel("Nama Pelanggan");
JLabel lb2 = new JLabel("Jenis Kelamin");
JRadioButton rdLaki=new JRadioButton("Laki-Laki");
JRadioButton rdPerempuan=new JRadioButton("Perempuan");
ButtonGroup buttonGroup1=new ButtonGroup();
JLabel lb3 = new JLabel("Nama Barang");
JLabel lb4 = new JLabel("Harga Barang");
JLabel lb5 = new JLabel("Banyaknya");
JLabel lb6 = new JLabel("Jumlah");
JLabel lb7 = new JLabel("Nama Barang");
JLabel lb8 = new JLabel("Harga Barang");
JLabel lb9 = new JLabel("Banyaknya");
JLabel lb10 = new JLabel("Jumlah");
JLabel lb11 = new JLabel("Nama Barang");
JLabel lb12 = new JLabel("Harga Barang");
JLabel lb13 = new JLabel("Banyaknya");
JLabel lb14 = new JLabel("Jumlah");
JLabel lb15 = new JLabel("Nama Barang");
JLabel lb16 = new JLabel("Harga Barang");
JLabel lb17 = new JLabel("Banyaknya");
JLabel lb18 = new JLabel("Jumlah");
JLabel lb19 = new JLabel("Nama Barang");
JLabel lb20 = new JLabel("Harga Barang");
JLabel lb21 = new JLabel("Banyaknya");
JLabel lb22 = new JLabel("Jumlah");
JLabel lb23 = new JLabel("Total Biaya ");
JTextField tfPelanggan = new JTextField();
JTextField tfBarang1 = new JTextField();
JTextField tfHarga1 = new JTextField();
JTextField tfBanyak1 = new JTextField();
JTextField tfJumlah1 = new JTextField();
JTextField tfBarang2 = new JTextField();
JTextField tfHarga2 = new JTextField();
JTextField tfBanyak2 = new JTextField();
JTextField tfJumlah2 = new JTextField();
JTextField tfBarang3 = new JTextField();
JTextField tfHarga3 = new JTextField();
JTextField tfBanyak3 = new JTextField();
JTextField tfJumlah3 = new JTextField();
JTextField tfBarang4 = new JTextField();
JTextField tfHarga4 = new JTextField();
JTextField tfBanyak4 = new JTextField();
JTextField tfJumlah4 = new JTextField();
JTextField tfBarang5 = new JTextField();
JTextField tfHarga5 = new JTextField();
JTextField tfBanyak5 = new JTextField();
JTextField tfJumlah5 = new JTextField();
JTextField tfTotal = new JTextField();
JButton btnHITUNG = new JButton("HITUNG");
JButton btnINPUTLAGI = new JButton("INPUT LAGI");
JButton btnSELESAI = new JButton("SELESAI");
JPanel panel = new JPanel();
Onderdil()
{
setTitle("15.01.53.0044 / DHIKA BAGAS WHISNU AJI / A2");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(660,520);
setLocationRelativeTo(null);
panel.setLayout(null);
lb100.setBounds(50,40,550,50);
lb100.setFont(new Font("Algerian", Font.PLAIN, 40));
lb1.setBounds(10,100,120,30);
lb2.setBounds(10,140,120,30);
tfPelanggan.setBounds(120,100,200,30);
rdLaki.setBounds(120,140,120,30);
rdPerempuan.setBounds(270,140,120,30);
lb3.setBounds(10,180,120,30);
tfBarang1.setBounds(120,180,80,30);
lb4.setBounds(210,180,120,30);
tfHarga1.setBounds(300,180,80,30);
lb5.setBounds(390,180,120,30);
tfBanyak1.setBounds(460,180,30,30);
lb6.setBounds(500,180,120,30);
tfJumlah1.setBounds(550,180,80,30);
lb7.setBounds(10,220,120,30);
tfBarang2.setBounds(120,220,80,30);
lb8.setBounds(210,220,120,30);
tfHarga2.setBounds(300,220,80,30);
lb9.setBounds(390,220,120,30);
tfBanyak2.setBounds(460,220,30,30);
lb10.setBounds(500,220,120,30);
tfJumlah2.setBounds(550,220,80,30);
lb11.setBounds(10,260,120,30);
tfBarang3.setBounds(120,260,80,30);
lb12.setBounds(210,260,120,30);
tfHarga3.setBounds(300,260,80,30);
lb13.setBounds(390,260,120,30);
tfBanyak3.setBounds(460,260,30,30);
lb14.setBounds(500,260,120,30);
tfJumlah3.setBounds(550,260,80,30);
lb15.setBounds(10,300,120,30);
tfBarang4.setBounds(120,300,80,30);
lb16.setBounds(210,300,120,30);
tfHarga4.setBounds(300,300,80,30);
lb17.setBounds(390,300,120,30);
tfBanyak4.setBounds(460,300,30,30);
lb18.setBounds(500,300,120,30);
tfJumlah4.setBounds(550,300,80,30);
lb19.setBounds(10,340,120,30);
tfBarang5.setBounds(120,340,80,30);
lb20.setBounds(210,340,120,30);
tfHarga5.setBounds(300,340,80,30);
lb21.setBounds(390,340,120,30);
tfBanyak5.setBounds(460,340,30,30);
lb22.setBounds(500,340,120,30);
tfJumlah5.setBounds(550,340,80,30);
lb23.setBounds(10,380,120,30);
tfTotal.setBounds(120,380,80,30);
btnHITUNG.setBounds(160,440,100,30);
btnINPUTLAGI.setBounds(270,440,100,30);
btnSELESAI.setBounds(380,440,100,30);
buttonGroup1.add(rdLaki);
buttonGroup1.add(rdPerempuan);
panel.add(lb100);
panel.add(lb1);
panel.add(lb2);
panel.add(tfPelanggan);
panel.add(rdLaki);
panel.add(rdPerempuan);
panel.add(lb3);
panel.add(tfBarang1);
panel.add(lb4);
panel.add(tfHarga1);
panel.add(lb5);
panel.add(tfBanyak1);
panel.add(lb6);
panel.add(tfJumlah1);
panel.add(lb7);
panel.add(tfBarang2);
panel.add(lb8);
panel.add(tfHarga2);
panel.add(lb9);
panel.add(tfBanyak2);
panel.add(lb10);
panel.add(tfJumlah2);
panel.add(lb11);
panel.add(tfBarang3);
panel.add(lb12);
panel.add(tfHarga3);
panel.add(lb13);
panel.add(tfBanyak3);
panel.add(lb14);
panel.add(tfJumlah3);
panel.add(lb15);
panel.add(tfBarang4);
panel.add(lb16);
panel.add(tfHarga4);
panel.add(lb17);
panel.add(tfBanyak4);
panel.add(lb18);
panel.add(tfJumlah4);
panel.add(lb19);
panel.add(tfBarang5);
panel.add(lb20);
panel.add(tfHarga5);
panel.add(lb21);
panel.add(tfBanyak5);
panel.add(lb22);
panel.add(tfJumlah5);
panel.add(lb23);
panel.add(tfTotal);
panel.add(btnHITUNG);
panel.add(btnINPUTLAGI);
panel.add(btnSELESAI);
btnHITUNG.addActionListener(this);
btnINPUTLAGI.addActionListener(this);
btnSELESAI.addActionListener(this);
add(panel);
}
public void actionPerformed(ActionEvent e)
{
Object objek = e.getSource();
if(objek==btnHITUNG)
{
String h1 = tfHarga1.getText();
String h2 = tfHarga2.getText();
String h3 = tfHarga3.getText();
String h4 = tfHarga4.getText();
String h5 = tfHarga5.getText();
String j1 = tfBanyak1.getText();
String j2 = tfBanyak2.getText();
String j3 = tfBanyak3.getText();
String j4 = tfBanyak4.getText();
String j5 = tfBanyak5.getText();
double a1 = Integer.parseInt(h1);
double b1 = Integer.parseInt(h2);
double c1 = Integer.parseInt(h3);
double d1 = Integer.parseInt(h4);
double e1 = Integer.parseInt(h5);
double v1 = Integer.parseInt(j1);
double w1 = Integer.parseInt(j2);
double x1 = Integer.parseInt(j3);
double y1 = Integer.parseInt(j4);
double z1 = Integer.parseInt(j5);
int Jumlah01 = (int) ((a1 * v1));
int Jumlah02 = (int) ((b1 * w1));
int Jumlah03 = (int) ((c1 * x1));
int Jumlah04 = (int) ((d1 * y1));
int Jumlah05 = (int) ((e1 * z1));
tfJumlah1.setText(new String().valueOf(Jumlah01));
tfJumlah2.setText(new String().valueOf(Jumlah02));
tfJumlah3.setText(new String().valueOf(Jumlah03));
tfJumlah4.setText(new String().valueOf(Jumlah04));
tfJumlah5.setText(new String().valueOf(Jumlah05));
int JumlahTotal = (int) ((Jumlah01 + Jumlah02 + Jumlah03 + Jumlah04 + Jumlah05));
tfTotal.setText(new String().valueOf(JumlahTotal));
}
else if(objek==btnINPUTLAGI)
{
tfPelanggan.setText("");
tfPelanggan.setText("");
tfBarang1.setText("");
tfHarga1.setText("");
tfBanyak1.setText("");
tfJumlah1.setText("");
tfBarang2.setText("");
tfHarga2.setText("");
tfBanyak2.setText("");
tfJumlah2.setText("");
tfBarang3.setText("");
tfHarga3.setText("");
tfBanyak3.setText("");
tfJumlah3.setText("");
tfBarang4.setText("");
tfHarga4.setText("");
tfBanyak4.setText("");
tfJumlah4.setText("");
tfBarang5.setText("");
tfHarga5.setText("");
tfBanyak5.setText("");
tfJumlah5.setText("");
tfTotal.setText("");
tfPelanggan.requestFocus();
JOptionPane.showMessageDialog(null, "Silahkan Input Lagi ");
}
else if (objek==btnSELESAI)
{
JOptionPane.showMessageDialog(null,"Terima kasih telah melihat program saya ");
System.exit(1);
}
}
public static void main(String[]args)
{
Onderdil frame=new Onderdil();
frame.setSize(660,520);
frame.setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
public class Onderdil extends JFrame implements ActionListener
{
JLabel lb100 = new JLabel("PENJUALAN ONDERDIL MOBIL");
JLabel lb1 = new JLabel("Nama Pelanggan");
JLabel lb2 = new JLabel("Jenis Kelamin");
JRadioButton rdLaki=new JRadioButton("Laki-Laki");
JRadioButton rdPerempuan=new JRadioButton("Perempuan");
ButtonGroup buttonGroup1=new ButtonGroup();
JLabel lb3 = new JLabel("Nama Barang");
JLabel lb4 = new JLabel("Harga Barang");
JLabel lb5 = new JLabel("Banyaknya");
JLabel lb6 = new JLabel("Jumlah");
JLabel lb7 = new JLabel("Nama Barang");
JLabel lb8 = new JLabel("Harga Barang");
JLabel lb9 = new JLabel("Banyaknya");
JLabel lb10 = new JLabel("Jumlah");
JLabel lb11 = new JLabel("Nama Barang");
JLabel lb12 = new JLabel("Harga Barang");
JLabel lb13 = new JLabel("Banyaknya");
JLabel lb14 = new JLabel("Jumlah");
JLabel lb15 = new JLabel("Nama Barang");
JLabel lb16 = new JLabel("Harga Barang");
JLabel lb17 = new JLabel("Banyaknya");
JLabel lb18 = new JLabel("Jumlah");
JLabel lb19 = new JLabel("Nama Barang");
JLabel lb20 = new JLabel("Harga Barang");
JLabel lb21 = new JLabel("Banyaknya");
JLabel lb22 = new JLabel("Jumlah");
JLabel lb23 = new JLabel("Total Biaya ");
JTextField tfPelanggan = new JTextField();
JTextField tfBarang1 = new JTextField();
JTextField tfHarga1 = new JTextField();
JTextField tfBanyak1 = new JTextField();
JTextField tfJumlah1 = new JTextField();
JTextField tfBarang2 = new JTextField();
JTextField tfHarga2 = new JTextField();
JTextField tfBanyak2 = new JTextField();
JTextField tfJumlah2 = new JTextField();
JTextField tfBarang3 = new JTextField();
JTextField tfHarga3 = new JTextField();
JTextField tfBanyak3 = new JTextField();
JTextField tfJumlah3 = new JTextField();
JTextField tfBarang4 = new JTextField();
JTextField tfHarga4 = new JTextField();
JTextField tfBanyak4 = new JTextField();
JTextField tfJumlah4 = new JTextField();
JTextField tfBarang5 = new JTextField();
JTextField tfHarga5 = new JTextField();
JTextField tfBanyak5 = new JTextField();
JTextField tfJumlah5 = new JTextField();
JTextField tfTotal = new JTextField();
JButton btnHITUNG = new JButton("HITUNG");
JButton btnINPUTLAGI = new JButton("INPUT LAGI");
JButton btnSELESAI = new JButton("SELESAI");
JPanel panel = new JPanel();
Onderdil()
{
setTitle("15.01.53.0044 / DHIKA BAGAS WHISNU AJI / A2");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(660,520);
setLocationRelativeTo(null);
panel.setLayout(null);
lb100.setBounds(50,40,550,50);
lb100.setFont(new Font("Algerian", Font.PLAIN, 40));
lb1.setBounds(10,100,120,30);
lb2.setBounds(10,140,120,30);
tfPelanggan.setBounds(120,100,200,30);
rdLaki.setBounds(120,140,120,30);
rdPerempuan.setBounds(270,140,120,30);
lb3.setBounds(10,180,120,30);
tfBarang1.setBounds(120,180,80,30);
lb4.setBounds(210,180,120,30);
tfHarga1.setBounds(300,180,80,30);
lb5.setBounds(390,180,120,30);
tfBanyak1.setBounds(460,180,30,30);
lb6.setBounds(500,180,120,30);
tfJumlah1.setBounds(550,180,80,30);
lb7.setBounds(10,220,120,30);
tfBarang2.setBounds(120,220,80,30);
lb8.setBounds(210,220,120,30);
tfHarga2.setBounds(300,220,80,30);
lb9.setBounds(390,220,120,30);
tfBanyak2.setBounds(460,220,30,30);
lb10.setBounds(500,220,120,30);
tfJumlah2.setBounds(550,220,80,30);
lb11.setBounds(10,260,120,30);
tfBarang3.setBounds(120,260,80,30);
lb12.setBounds(210,260,120,30);
tfHarga3.setBounds(300,260,80,30);
lb13.setBounds(390,260,120,30);
tfBanyak3.setBounds(460,260,30,30);
lb14.setBounds(500,260,120,30);
tfJumlah3.setBounds(550,260,80,30);
lb15.setBounds(10,300,120,30);
tfBarang4.setBounds(120,300,80,30);
lb16.setBounds(210,300,120,30);
tfHarga4.setBounds(300,300,80,30);
lb17.setBounds(390,300,120,30);
tfBanyak4.setBounds(460,300,30,30);
lb18.setBounds(500,300,120,30);
tfJumlah4.setBounds(550,300,80,30);
lb19.setBounds(10,340,120,30);
tfBarang5.setBounds(120,340,80,30);
lb20.setBounds(210,340,120,30);
tfHarga5.setBounds(300,340,80,30);
lb21.setBounds(390,340,120,30);
tfBanyak5.setBounds(460,340,30,30);
lb22.setBounds(500,340,120,30);
tfJumlah5.setBounds(550,340,80,30);
lb23.setBounds(10,380,120,30);
tfTotal.setBounds(120,380,80,30);
btnHITUNG.setBounds(160,440,100,30);
btnINPUTLAGI.setBounds(270,440,100,30);
btnSELESAI.setBounds(380,440,100,30);
buttonGroup1.add(rdLaki);
buttonGroup1.add(rdPerempuan);
panel.add(lb100);
panel.add(lb1);
panel.add(lb2);
panel.add(tfPelanggan);
panel.add(rdLaki);
panel.add(rdPerempuan);
panel.add(lb3);
panel.add(tfBarang1);
panel.add(lb4);
panel.add(tfHarga1);
panel.add(lb5);
panel.add(tfBanyak1);
panel.add(lb6);
panel.add(tfJumlah1);
panel.add(lb7);
panel.add(tfBarang2);
panel.add(lb8);
panel.add(tfHarga2);
panel.add(lb9);
panel.add(tfBanyak2);
panel.add(lb10);
panel.add(tfJumlah2);
panel.add(lb11);
panel.add(tfBarang3);
panel.add(lb12);
panel.add(tfHarga3);
panel.add(lb13);
panel.add(tfBanyak3);
panel.add(lb14);
panel.add(tfJumlah3);
panel.add(lb15);
panel.add(tfBarang4);
panel.add(lb16);
panel.add(tfHarga4);
panel.add(lb17);
panel.add(tfBanyak4);
panel.add(lb18);
panel.add(tfJumlah4);
panel.add(lb19);
panel.add(tfBarang5);
panel.add(lb20);
panel.add(tfHarga5);
panel.add(lb21);
panel.add(tfBanyak5);
panel.add(lb22);
panel.add(tfJumlah5);
panel.add(lb23);
panel.add(tfTotal);
panel.add(btnHITUNG);
panel.add(btnINPUTLAGI);
panel.add(btnSELESAI);
btnHITUNG.addActionListener(this);
btnINPUTLAGI.addActionListener(this);
btnSELESAI.addActionListener(this);
add(panel);
}
public void actionPerformed(ActionEvent e)
{
Object objek = e.getSource();
if(objek==btnHITUNG)
{
String h1 = tfHarga1.getText();
String h2 = tfHarga2.getText();
String h3 = tfHarga3.getText();
String h4 = tfHarga4.getText();
String h5 = tfHarga5.getText();
String j1 = tfBanyak1.getText();
String j2 = tfBanyak2.getText();
String j3 = tfBanyak3.getText();
String j4 = tfBanyak4.getText();
String j5 = tfBanyak5.getText();
double a1 = Integer.parseInt(h1);
double b1 = Integer.parseInt(h2);
double c1 = Integer.parseInt(h3);
double d1 = Integer.parseInt(h4);
double e1 = Integer.parseInt(h5);
double v1 = Integer.parseInt(j1);
double w1 = Integer.parseInt(j2);
double x1 = Integer.parseInt(j3);
double y1 = Integer.parseInt(j4);
double z1 = Integer.parseInt(j5);
int Jumlah01 = (int) ((a1 * v1));
int Jumlah02 = (int) ((b1 * w1));
int Jumlah03 = (int) ((c1 * x1));
int Jumlah04 = (int) ((d1 * y1));
int Jumlah05 = (int) ((e1 * z1));
tfJumlah1.setText(new String().valueOf(Jumlah01));
tfJumlah2.setText(new String().valueOf(Jumlah02));
tfJumlah3.setText(new String().valueOf(Jumlah03));
tfJumlah4.setText(new String().valueOf(Jumlah04));
tfJumlah5.setText(new String().valueOf(Jumlah05));
int JumlahTotal = (int) ((Jumlah01 + Jumlah02 + Jumlah03 + Jumlah04 + Jumlah05));
tfTotal.setText(new String().valueOf(JumlahTotal));
}
else if(objek==btnINPUTLAGI)
{
tfPelanggan.setText("");
tfPelanggan.setText("");
tfBarang1.setText("");
tfHarga1.setText("");
tfBanyak1.setText("");
tfJumlah1.setText("");
tfBarang2.setText("");
tfHarga2.setText("");
tfBanyak2.setText("");
tfJumlah2.setText("");
tfBarang3.setText("");
tfHarga3.setText("");
tfBanyak3.setText("");
tfJumlah3.setText("");
tfBarang4.setText("");
tfHarga4.setText("");
tfBanyak4.setText("");
tfJumlah4.setText("");
tfBarang5.setText("");
tfHarga5.setText("");
tfBanyak5.setText("");
tfJumlah5.setText("");
tfTotal.setText("");
tfPelanggan.requestFocus();
JOptionPane.showMessageDialog(null, "Silahkan Input Lagi ");
}
else if (objek==btnSELESAI)
{
JOptionPane.showMessageDialog(null,"Terima kasih telah melihat program saya ");
System.exit(1);
}
}
public static void main(String[]args)
{
Onderdil frame=new Onderdil();
frame.setSize(660,520);
frame.setVisible(true);
}
}
Hasil Tampilan :
No comments:
Post a Comment