Untuk Listingnya Monggo Di lihat ( maaf acak2kan )
//LATIHAN PENJUALAN MOBIL
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package latihan;
/**
*
* @author Admins
*/
public class mobil extends javax.swing.JFrame {
int ac,central,kaca,total,bayar,harga,rd2,rd1;
/**
* Creates new form mobil
*/
public mobil() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
rd_1 = new javax.swing.JRadioButton();
rd_2 = new javax.swing.JRadioButton();
cek_ac = new javax.swing.JCheckBox();
cek_central = new javax.swing.JCheckBox();
cek_kaca = new javax.swing.JCheckBox();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
t_nama = new javax.swing.JTextField();
t_harga = new javax.swing.JTextField();
t_bayar = new javax.swing.JTextField();
t_ac = new javax.swing.JTextField();
t_central = new javax.swing.JTextField();
t_kaca = new javax.swing.JTextField();
t_total = new javax.swing.JTextField();
cmb_kode = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("KODE MOBIL");
jLabel2.setText("NAMA MOBIL");
jLabel3.setText("HARGA MOBIL");
buttonGroup1.add(rd_1);
rd_1.setText("CC / DC");
rd_1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rd_1ActionPerformed(evt);
}
});
buttonGroup1.add(rd_2);
rd_2.setText("CASH");
rd_2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rd_2ActionPerformed(evt);
}
});
cek_ac.setText("A C");
cek_ac.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cek_acActionPerformed(evt);
}
});
cek_central.setText("CENTRAL LOCK");
cek_central.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cek_centralActionPerformed(evt);
}
});
cek_kaca.setText("KACA FILM");
cek_kaca.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cek_kacaActionPerformed(evt);
}
});
jLabel4.setText("TOTAL BAYAR");
jButton1.setText("BERSIH");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("KELUAR");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
cmb_kode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--PILIH KODE MOBIL--", "MAV01", "MXE02", "MIN03", " " }));
cmb_kode.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmb_kodeActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(54, 54, 54)
.addComponent(jButton2))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addGroup(layout.createSequentialGroup()
.addComponent(rd_1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rd_2))
.addComponent(cek_ac)
.addComponent(cek_central)
.addComponent(cek_kaca)
.addComponent(jLabel4)
.addComponent(jLabel1))
.addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(t_total)
.addComponent(t_nama, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
.addComponent(cmb_kode, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t_kaca, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
.addComponent(t_central)
.addComponent(t_ac)
.addComponent(t_bayar)
.addComponent(t_harga))))
.addContainerGap(46, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(cmb_kode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(t_nama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(t_harga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(rd_1)
.addComponent(rd_2)
.addComponent(t_bayar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cek_ac)
.addComponent(t_ac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cek_central)
.addComponent(t_central, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cek_kaca)
.addComponent(t_kaca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(t_total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
}//
private void rd_1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rd_1.isSelected()){
int a=Integer.parseInt(t_harga.getText());
int b=125000;
int c=a+b;
t_bayar.setText(String.valueOf(b));
t_total.setText(String.valueOf(c));
}
}
private void rd_2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rd_2.isSelected()){
int a=Integer.parseInt(t_harga.getText());
int b=150000;
int c=a+b;
t_bayar.setText(String.valueOf(b));
t_total.setText(String.valueOf(c));
}
}
private void cmb_kodeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(cmb_kode.getSelectedItem().equals("MAV01")){
t_nama.setText("AVANZA");
harga=125000000;
t_harga.setText(String.valueOf(harga));
if(t_total.getText().equals("")){
bayar=0;
}
else
{
bayar=Integer.parseInt(t_total.getText());
}
total=harga;
t_total.setText(String.valueOf(total));
}
else if(cmb_kode.getSelectedItem().equals("MXE02")){
t_nama.setText("XENIA");
harga=115000000;
t_harga.setText(String.valueOf(harga));
if(t_total.getText().equals("")){
bayar=0;
}
else
{
bayar=Integer.parseInt(t_total.getText());
}
total=harga;
t_total.setText(String.valueOf(total));
}
else if(cmb_kode.getSelectedItem().equals("MIN03")){
t_nama.setText("INNOVA");
harga=135000000;
t_harga.setText(String.valueOf(harga));
if(t_total.getText().equals("")){
bayar=0;
}
else
{
bayar=Integer.parseInt(t_total.getText());
}
total=bayar+harga;
t_total.setText(String.valueOf(total));
}
}
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
buttonGroup1.clearSelection();
cek_ac.setSelected(false);
cek_central.setSelected(false);
cek_kaca.setSelected(false);
t_nama.setText("");
t_harga.setText("");
t_bayar.setText("");
t_ac.setText("");
t_central.setText("");
t_kaca.setText("");
t_total.setText("0");
cmb_kode.setSelectedItem("--PILIH KODE MOBIL--");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cek_kacaActionPerformed(java.awt.event.ActionEvent evt) {
if(cek_kaca.isSelected()){
kaca=300000;
if(rd_2.isSelected()){
rd2=150000;
t_bayar.setText(String.valueOf(rd2));
total=ac+central+kaca+bayar+harga+rd2;
rd2=150000;
}
if(rd_1.isSelected()){
rd2=125000;
t_bayar.setText(String.valueOf(rd2));
total=ac+central+kaca+bayar+harga+rd2;
rd2=125000;
}
t_bayar.setText(String.valueOf(bayar));
t_kaca.setText(String.valueOf(kaca));
t_total.setText(String.valueOf(total));
total=ac+central+kaca+bayar+harga+rd2;
}
else
{
ac=0;
total=ac+central+kaca+bayar+harga+rd2+rd1;
t_bayar.setText(String.valueOf(rd2));
t_kaca.setText(String.valueOf(kaca));
t_total.setText(String.valueOf(total));
} // TODO add your handling code here:
}
private void cek_acActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(cek_ac.isSelected()){
ac=200000;
if(rd_2.isSelected()){
rd2=150000;
t_bayar.setText(String.valueOf(rd2));
total=ac+central+kaca+bayar+harga+rd2;
rd2=150000;
}
if(rd_1.isSelected()){
rd2=125000;
t_bayar.setText(String.valueOf(rd2));
total=ac+central+kaca+bayar+harga+rd2;
rd2=125000;
}
t_bayar.setText(String.valueOf(bayar));
t_ac.setText(String.valueOf(ac));
t_total.setText(String.valueOf(total));
total=ac+central+kaca+bayar+harga+rd2;
}
else
{
ac=0;
total=ac+central+kaca+bayar+harga+rd2+rd1;
t_bayar.setText(String.valueOf(rd2));
t_ac.setText(String.valueOf(ac));
t_total.setText(String.valueOf(total));
}
}
private void cek_centralActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(cek_central.isSelected()){
central=250000;
if(rd_2.isSelected()){
rd2=150000;
t_bayar.setText(String.valueOf(rd2));
total=ac+central+kaca+bayar+harga+rd2;
rd2=150000;
}
if(rd_1.isSelected()){
rd2=125000;
t_bayar.setText(String.valueOf(rd2));
total=ac+central+kaca+bayar+harga+rd2;
rd2=125000;
}
t_bayar.setText(String.valueOf(bayar));
t_central.setText(String.valueOf(central));
t_total.setText(String.valueOf(total));
total=ac+central+kaca+bayar+harga+rd2;
}
else
{
ac=0;
total=ac+central+kaca+bayar+harga+rd2+rd1;
t_bayar.setText(String.valueOf(rd2));
t_central.setText(String.valueOf(central));
t_total.setText(String.valueOf(total));
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(mobil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(mobil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(mobil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(mobil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new mobil().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JCheckBox cek_ac;
private javax.swing.JCheckBox cek_central;
private javax.swing.JCheckBox cek_kaca;
private javax.swing.JComboBox cmb_kode;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JRadioButton rd_1;
private javax.swing.JRadioButton rd_2;
private javax.swing.JTextField t_ac;
private javax.swing.JTextField t_bayar;
private javax.swing.JTextField t_central;
private javax.swing.JTextField t_harga;
private javax.swing.JTextField t_kaca;
private javax.swing.JTextField t_nama;
private javax.swing.JTextField t_total;
// End of variables declaration
}