Laman

Selamat Datang Sahabat! Selamat ber-sharing Ilmu Komputer

Sabtu, 28 Desember 2013

Java Program : JFrame Form Terstruktur

Design Form tersebut diatas! Dengan Class Name: FormJualMobil

Tuliskan Listing berikut dibawah "Package"

import javax.swing.JOptionPane;

public class FormJualMobil extends javax.swing.JFrame {
    private int hrg, ttl, ac, central, kaca;
    private String merk;

 public FormJualMobil() {
        initComponents();
        setLocationRelativeTo(this);
    }

 private void bkeluarActionPerformed(java.awt.event.ActionEvent evt) {                                        
  System.exit(0);
    }                                       

    private void bbersihActionPerformed(java.awt.event.ActionEvent evt) {                                        
        cbkode.setSelectedItem("-PILIH-");
        tmerk.setText("");
        tharga.setText("");
        tac.setText("");
        tcentral.setText("");
        tkaca.setText("");
        ttotal.setText("");
        cac.setSelected(false);
        ccentral.setSelected(false);
        ckaca.setSelected(false);
    }                                       

    private void cbkodeActionPerformed(java.awt.event.ActionEvent evt) {                                       
        if (cbkode.getSelectedItem().equals("MAV01"))
           { merk="AVANZA";
            hrg=125000000;}
        else if (cbkode.getSelectedItem().equals("MXE02"))
           { merk="XENIA";
            hrg=115000000;}
         else if (cbkode.getSelectedItem().equals("MIN03"))
           { merk="INOVA";
            hrg=135000000;}
        tmerk.setText(merk);
        tharga.setText(String.valueOf(hrg));
        total();
        ttotal.setText(String.valueOf(ttl));
    }                                      

    private void cacActionPerformed(java.awt.event.ActionEvent evt) {                                    
        if (cac.isSelected()==true )
        { ac=20000; }
        else {ac=0;}
        tac.setText(String.valueOf(ac));
         total();
         ttotal.setText(String.valueOf(ttl));
    }                                   

    private void ccentralActionPerformed(java.awt.event.ActionEvent evt) {                                         
        if (ccentral.isSelected()==true )
        { central=10000; }
        else {central=0;}
        tcentral.setText(String.valueOf(central));
         total();
         ttotal.setText(String.valueOf(ttl));
    }                                        

    private void ckacaActionPerformed(java.awt.event.ActionEvent evt) {                                      
       if (ckaca.isSelected()==true )
        { kaca=20000; }
        else {kaca=0;}
        tkaca.setText(String.valueOf(kaca));
         total();
         ttotal.setText(String.valueOf(ttl));
    }                                     

    void total()
    { ttl=hrg+ac+kaca+central; }

Rabu, 25 Desember 2013

Java Program : JFrame Form berbasis OOP

a.            Membuat Project, Klik File -> New Project -> Java -> Java Application. Project Name : KUIS
b.            Membuat Class KUIS, Klik kanan pada package kuis -> New -> Java Class. Class Name: KUIS

Tulis script dibawah ini didalam Java Class "KUIS"
package kuis;
public class KUIS {
    public double gapok,tunjangan,tunjanak, tunjistri,bbulan,btahun,pinj,gajibersih;
    public String golongan;

    public String getGolongan() {
        return golongan;    }

    public void setGolongan(String golongan) {
        this.golongan = golongan; }
   
    public void setPilihGolongan()
    {if (golongan.equalsIgnoreCase("3A"))
        { gapok=5000000;
          tunjangan=500000;}
   else if (golongan.equalsIgnoreCase("3B"))
        { gapok=3500000;
          tunjangan=350000;}
   else  { gapok=2000000;
          tunjangan=100000;}
    }

    public double getGapok() {
        return gapok;    }

    public void setGapok(double gapok) {
        this.gapok = gapok;    }

    public double getTunjangan() {
        return tunjangan;    }

    public void setTunjangan(double tunjangan) {
        this.tunjangan = tunjangan;    }

    public double getTunjanak() {
        tunjanak=150000;
        return tunjanak;    }

    public void setTunjanak(double tunjanak) {
        this.tunjanak = tunjanak;    }

    public double getTunjistri() {
        tunjistri=200000;
        return tunjistri;    }

    public void setTunjistri(double tunjistri) {
        this.tunjistri = tunjistri;    }

    public double getBbulan() {
       bbulan=200000;
        return bbulan;    }

    public void setBbulan(double bbulan) {
        this.bbulan = bbulan;    }

    public double getBtahun() {
        btahun=500000;
        return btahun;  }

    public void setBtahun(double btahun) {
        this.btahun = btahun;  }

    public double getPinj() {
        return pinj; }

    public void setPinj(double pinj) {
        this.pinj = pinj;  }

    public double getGajibersih() {
        gajibersih=gapok+tunjangan+tunjistri+tunjanak+bbulan+btahun-pinj;
        return gajibersih;  }

    public void setGajibersih(double gajibersih) {
        this.gajibersih = gajibersih;  }



c.            Buat dan Design Form Penggajian dibawah ini, Klik kanan pada package kuis -> New -> JFrame From. Class Name: FormPenggajian


Tuliskan script dibawah ini pada Form Penggajian

package kuis;
public class FormPenggajian extends javax.swing.JFrame {
    KUIS kuis = new KUIS();
public FormPenggajian() {
        initComponents();
        setLocationRelativeTo(this);
    }
private void bkeluarActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        System.exit(0);
    }                                      

    private void bbersihActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        tnip.setText("");
         tnama.setText("");
          tgapok.setText("");
           ttunjangan.setText("");
            ttunjlain.setText("");
             tbonus.setText("");
              tpinjaman.setText("");
               tgajibersih.setText("");
               golongan.clearSelection();
             tnip.requestFocus();
    }                                       

    private void golaActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        kuis.setGolongan(gola.getText());
        kuis.setPilihGolongan();
        tgapok.setText(Double.toString(kuis.getGapok()));
       ttunjangan.setText(Double.toString(kuis.getTunjangan()));
      
    }                                   

    private void golbActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
          kuis.setGolongan(golb.getText());
        kuis.setPilihGolongan();
        tgapok.setText(Double.toString(kuis.getGapok()));
       ttunjangan.setText(Double.toString(kuis.getTunjangan()));
    }                                   

    private void golcActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
          kuis.setGolongan(golc.getText());
        kuis.setPilihGolongan();
        tgapok.setText(Double.toString(kuis.getGapok()));
       ttunjangan.setText(Double.toString(kuis.getTunjangan()));
    }                                   

    private void cbistriActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
         if (cbistri.isSelected()==true && cbanak.isSelected()==false )
        { ttunjlain.setText(Double.toString(kuis.getTunjistri()));}
           else if (cbistri.isSelected()==false && cbanak.isSelected()==true )
        { ttunjlain.setText(Double.toString(kuis.getTunjanak()));}
         else if (cbistri.isSelected()==true && cbanak.isSelected()==true)
        { ttunjlain.setText(Double.toString(kuis.getTunjistri()+kuis.getTunjanak()));}
           else
        { ttunjlain.setText("");}
    }                                      

    private void cbanakActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
         if (cbistri.isSelected()==true && cbanak.isSelected()==false )
        { ttunjlain.setText(Double.toString(kuis.getTunjistri()));}
          else if (cbistri.isSelected()==false && cbanak.isSelected()==true )
        { ttunjlain.setText(Double.toString(kuis.getTunjanak()));}
         else if (cbistri.isSelected()==true && cbanak.isSelected()==true)
        { ttunjlain.setText(Double.toString(kuis.getTunjistri()+kuis.getTunjanak()));}
           else
        { ttunjlain.setText("");}
    }                                     

    private void cbbulanActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
         if (cbbulan.isSelected()==true && cbtahun.isSelected()==false)
        { tbonus.setText(Double.toString(kuis.getBbulan()));}
          else if (cbbulan.isSelected()==false && cbtahun.isSelected()==true)
        { tbonus.setText(Double.toString(kuis.getBtahun()));}
           else if (cbbulan.isSelected()==true && cbtahun.isSelected()==true)
        { tbonus.setText(Double.toString(kuis.getBbulan()+kuis.getBtahun()));}
           else
               { tbonus.setText("");}
    }                                      

    private void cbtahunActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
            if (cbbulan.isSelected()==true && cbtahun.isSelected()==false)
        { tbonus.setText(Double.toString(kuis.getBbulan()));}
          else if (cbbulan.isSelected()==false && cbtahun.isSelected()==true)
        { tbonus.setText(Double.toString(kuis.getBtahun()));}
           else if (cbbulan.isSelected()==true && cbtahun.isSelected()==true)
        { tbonus.setText(Double.toString(kuis.getBbulan()+kuis.getBtahun()));}
           else
               { tbonus.setText("");}
    }                                      

    private void bhitungActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
         kuis.setPinj(Double.parseDouble(tpinjaman.getText()));
         tgajibersih.setText(Double.toString(kuis.getGajibersih()));
    }                                       

Rabu, 27 November 2013

Java Program : JFrame "TOSERBA VAN JAVA"

Lihat dan Design tampilan JFrame dibawah ini :
Dengan ketentuan dibawah ini:
Sekarang, kita lihat Listing programnya!

Pertama Kita buat Javaclass dengan nama "FormBarang"

package javaform;

public class FormBarang {
public String kd,nm;
public int jml;
public double hrg,ttl,ub,uk;
public void setKd(String val)
{ kd=val; }
public String getKd()
{ return kd; }
public void setSeleksiKd()
{ if (kd.equalsIgnoreCase("B001"))
{ nm="PENSIL";
hrg=3000; }
else if (kd.equalsIgnoreCase("B002"))
{ nm="BUKU";
hrg=5000; }
else if (kd.equalsIgnoreCase("B003"))
{ nm="PENGGARIS";
hrg=1000; }
else if (kd.equalsIgnoreCase("B004"))
{ nm="PENGHAPUS";
hrg=500; }
else
{ nm="";
hrg=0;}
}

public void setNm(String val)
{ nm = val; }
public String getNm()
{ return nm; }
public void setHrg(Double val)
{ hrg = val; }
public double getHrg()
{ return hrg; }

public void setJml(int val)
{ jml=val; }
public int getJml()
{ return jml; }
public void setTot(Double val)
{ ttl=val; }
public double getTot()
{ ttl=hrg*jml;
return(ttl); }

public void setUb(Double val)
{ ub=val; }
public double getUb()
{ return ub; }
public double getUk()
{ uk=ub-ttl;
return uk; }
}



Kedua, buat JFrame dengan nama "FormBarang1"

package javaform;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;

public class FormBarang1 extends javax.swing.JFrame {
FormBarang brg = new FormBarang();

public FormBarang1() {
initComponents();
bersih();
nonaktif();
setLocationRelativeTo(this); //untuk tampil ditengah layar
}

private void bbersihActionPerformed(java.awt.event.ActionEvent evt) {
aktif();
bersih();
ckode.requestFocus();
}

private void bkeluarActionPerformed(java.awt.event.ActionEvent evt) {
int x;
x=JOptionPane.showConfirmDialog(null,"Yakin Mau Keluar?","Konfirmasi",JOptionPane.YES_NO_OPTION);
if (x==JOptionPane.YES_OPTION)
dispose();
else
return;
}

private void tjumlahKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode()==KeyEvent.VK_ENTER)
{ brg.setJml(Integer.parseInt(tjumlah.getText()));
ttotal.setText(Double.toString(brg.getTot()));
tubay.grabFocus();
}
}

private void tubayKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode()==KeyEvent.VK_ENTER)
{ brg.setUb(Double.parseDouble(tubay.getText()));
tukem.setText(Double.toString(brg.getUk()));
if(brg.getUb() { JOptionPane.showMessageDialog(null,"Maaf, Pembayaran Anda Kurang!!","Warning",JOptionPane.OK_OPTION);
tukem.setText("");
tubay.setText("");}
else { return; }
}
}


private void ckodeActionPerformed(java.awt.event.ActionEvent evt) {
brg.setKd(ckode.getSelectedItem().toString());
brg.setSeleksiKd();
tnama.setText((brg.getNm()));
tharga.setText(Double.toString(brg.getHrg()));
tjumlah.requestFocus();
}


void bersih()
{ ckode.setSelectedItem("--Pilih--");
tnama.setText("");
tharga.setText("");
tjumlah.setText("");
ttotal.setText("");
tubay.setText("");
tukem.setText(""); }

void aktif()
{ ckode.setEnabled(true);
tjumlah.setEnabled(true);
tubay.setEnabled(true); }

void nonaktif()
{ ckode.setEnabled(false);
tnama.setEnabled(false);
tharga.setEnabled(false);
tjumlah.setEnabled(false);
ttotal.setEnabled(false);
tubay.setEnabled(false);
tukem.setEnabled(false); }

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormBarang1().setVisible(true);
}
});
}}


Untuk Running, silahkan tekan Ctrl+F6 pada JFrame "FormBarang1"

Senin, 28 Oktober 2013

Java Program : JFrame dengan 5 Class

Lihat tampilan outputnya dahulu,



LISTING PROGRAM

Pertama kita membuat Empty Class yang bernama "Mahasiswa"
package tugasjava;
import javax.swing.*;

public class Mahasiswa extends TugasJava1{
    
    public int getNim()
    { return nim; }
    public void setTekMhs(){
        if (nim==12115155)
        { nmmhs="Bayu Sugara"; }
        else if (nim==12117196)
        { nmmhs="Muhammad Umar Fauzi"; }
        else if (nim==12114602)
        { nmmhs="Aris Joko Purnomo"; }
        else if (nim==12117616)
        { nmmhs="Barkah Nugraha"; }
        else if (nim==12112769)
        { nmmhs="Hendra Septian"; }
        else if (nim==12115444)
        { nmmhs="Mochammad Idrus Asna"; }
        else { nmmhs="SALAH KODE!"; }}
    public String getNm()
    { return nmmhs; }
}


Kedua, membuat Empty Class dengan nama "Matkul"
package tugasjava;
import javax.swing.*;

public class Matkul extends TugasJava1{
     public void setTekMatkul()
    { if(kdmatkul==525)
        { matkul="Pemrograman Berbasis Objek I";
          nmdosen="Dony Oscar, S.Kom";
          sks=4;}
      else if(kdmatkul==635)
        { matkul="Pemodelan Sistem Berbasis Objek";
          nmdosen="Agustina Merdekawati, S.Kom"; 
          sks=4;}
      else if(kdmatkul==803)
        { matkul="Jaringan Komputer";
          nmdosen="Martini, S.Kom"; 
          sks=4;}
     else
        { matkul="-";
          nmdosen="-"; 
          sks=0;}}
     public int getKdmatkul()
     { return kdmatkul; }
     public String getMatkul()
     { return matkul; }
     public int getSks()
     { return sks; }
     public String getDosen()
     { return nmdosen; }   
}


Ketiga, membuat Empty Class dengan nama "Nilai"
package tugasjava;
import javax.swing.*;

public class Nilai extends TugasJava1{
     public void setTekNilai()
    { if (nilai>100)
    { grade=" ";
      ket=" ";}
    else if (nilai <= 100 &&nilai >= 80 )
        { grade="A";
          ket="Lulus";}
      else if (nilai < 80 && nilai >=70 )
        { grade="B";
           ket="Lulus";}
      else if (nilai < 70 && nilai >=60 )
        { grade="C";
           ket="Lulus";}
      else if (nilai < 60 && nilai >=50 )
        { grade="D";
            ket="Tidak Lulus";}
      else { grade="E"; 
               ket="Tidak Lulus";} }
     public int getNilai()
     { return nilai; }
     public String getGrade()
     { return grade; }
     public String getKet()
     { return ket; }    
}


Keempat, membuat Empty Class. Disini dinamain "TugasJava1"
package tugasjava;

public class TugasJava1{
    public int nim,nilai,kdmatkul,sks;
    public String nmmhs,grade,ket,nmdosen,matkul;
    public void setNim( Integer val)
    { nim=val;}
    public void setNm( String val)
    { nmmhs=val; }
      public void setKdmatkul( Integer val)
    { kdmatkul=val; }
    public void setSks( Integer val)
    { sks=val; }
    public void setDosen( String val)
    { nmdosen=val; }
    public void setNilai ( Integer val )
    { nilai = val; }
    public void setGrade( String val)
    { grade = val;}
    public void setket( String val)
    { grade = val;}
    public void setTekMhs()
    { return; }
    public void setTekNilai()
    { return; }
    public void setTekMatkul()
    { return; }
}


Dan, yang terakhir membuat Main Class dengan Nama "TugasTugas"
package tugasjava;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class TugasTugas extends JFrame implements ActionListener{
     private JLabel jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8,jLabel9;
     private JTextField tnim,tkdmatkul, tnmhs,tmatkul,tsks,tnmdosen,tnilai,tgrade,tket;
     private JButton bcekmhs,bcekmt,bceknl, bbersih, bkeluar;
     
     Mahasiswa mhs = new Mahasiswa();
     Matkul mt = new Matkul();
     Nilai nl = new Nilai();
     TugasJava1 tj = new TugasJava1();

     public TugasTugas (){
         setTitle("FORM PERHITUNGAN NILAI");
         setSize(500,400);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setLayout(null);
  
         jLabel1 = new JLabel("NIM");
         jLabel2 = new JLabel("Nama Mahasiswa");
         jLabel3 = new JLabel("Kode Mata Kuliah");
         jLabel4 = new JLabel("Mata kuliah");
         jLabel5 = new JLabel("SKS");
         jLabel6 = new JLabel("Nama Dosen");
         jLabel7 = new JLabel("Nilai");
         jLabel8 = new JLabel("Grade");
         jLabel9 = new JLabel("Keterangan");
         
         tkdmatkul = new JTextField("");
         tnim = new JTextField("");
         tnmhs = new JTextField("");
           tnmhs.setEditable(false);
         tmatkul = new JTextField("");
           tmatkul.setEditable(false);
         tsks = new JTextField("");
           tsks.setEditable(false);
         tnmdosen = new JTextField("");
           tnmdosen.setEditable(false);
         tnilai = new JTextField("");
         tgrade = new JTextField("");
           tgrade.setEditable(false);
         tket = new JTextField("");
           tket.setEditable(false); 
           
         bcekmhs = new JButton("CEK NIM");
         bcekmt = new JButton("CEK MATKUL");
         bceknl = new JButton("LIHAT");
         bbersih = new JButton("BERSIH");
         bkeluar = new JButton("KELUAR");
   
         add(jLabel1);
         add(jLabel2);
         add(jLabel3);
         add(jLabel4);
         add(jLabel5);
         add(jLabel6);
         add(jLabel7);
         add(jLabel8);
         add(jLabel9);
         add(tnim);
         add(tnmhs);
         add(tkdmatkul);
         add(tmatkul);
         add(tsks);
         add(tnmdosen);
         add(tnilai);
         add(tgrade);
         add(tket);
         add(bbersih);
         add(bceknl);
         add(bkeluar);
         add(bcekmhs);
         add(bcekmt);
  
        jLabel1.setBounds(30,70,80,25);
        jLabel2.setBounds(30,100,120,25);
        jLabel3.setBounds(30,130,80,25);
        jLabel4.setBounds(30,160,80,25);
        jLabel5.setBounds(30,190,80,25);
        jLabel6.setBounds(30,220,80,25);
        jLabel7.setBounds(30,250,80,25);
        jLabel8.setBounds(30,280,80,25);
        jLabel9.setBounds(30,310,80,25);
        tnim.setBounds(150,70,80,20);
        tnmhs.setBounds(150,100,140,20);
        tkdmatkul.setBounds(150,130,80,20);
        tmatkul.setBounds(150,160,180,20);
        tsks.setBounds(150,190,80,20);
        tnmdosen.setBounds(150,220,150,20);
        tnilai.setBounds(150,250,40,20);
        tgrade.setBounds(150,280,40,20);
        tket.setBounds(150,310,80,20);
        bcekmt.setBounds(235,130,110,20);
        bceknl.setBounds(200,250,100,20);
        bcekmhs.setBounds(235,70,90,20);
        bbersih.setBounds(350,200,100,40);
        bkeluar.setBounds(350,250,100,40);
  
         bcekmhs.addActionListener(this);
         bcekmt.addActionListener(this);
         bceknl.addActionListener(this);
         bbersih.addActionListener(this);
         bkeluar.addActionListener(this);
  }
     
  public void actionPerformed(ActionEvent e) {
  Object tombol = e.getSource();
  if (tombol==bceknl)
  { nl.setNilai(Integer.parseInt(tnilai.getText()));
    nl.setTekNilai();
    tgrade.setText(nl.getGrade());
    tket.setText(nl.getKet()); 
    tkdmatkul.requestFocus();}
  else if (tombol==bcekmhs)
  { mhs.setNim(Integer.parseInt(tnim.getText()));
    mhs.setTekMhs();
    tnmhs.setText(mhs.getNm()); }
  else if (tombol==bcekmt)
  { mt.setKdmatkul(Integer.parseInt(tkdmatkul.getText()));
    mt.setTekMatkul();
   tmatkul.setText(mt.getMatkul()); 
    tsks.setText(Integer.toString(mt.getSks()));
    tnmdosen.setText(mt.getDosen());}
  else if(tombol==bbersih)
  { tnim.setText("");
    tkdmatkul.setText("");
    tnmhs.setText("");
    tmatkul.setText("");
    tsks.setText("");
    tnmdosen.setText("");
    tnilai.setText("");
    tgrade.setText("");
    tket.setText(""); }
  else if(tombol==bkeluar)
  { int x;
        x=JOptionPane.showConfirmDialog(null,"Yakin Mau Keluar?","Konfirmasi",JOptionPane.YES_NO_OPTION);
        if (x==JOptionPane.YES_OPTION)
            dispose();
        else return; }}
      
  public static void main (String args[]){
      TugasTugas mn = new TugasTugas ();
      mn.setVisible(true);
   }
}


Untuk Running silahkan tekan Shift+F6 pada class "TugasTugas" ( Class terakhir )

SELAMAT MENCOBA...!!!

Minggu, 27 Oktober 2013

Java Program : JFrame dengan 1 Class

Sekarang, kita akan membahas Java Program Netbeans menggunakan JFrame ( From ) Sederhana dengan 1 Class,

Listing Program

package tugasjava;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class NewMain extends JFrame implements ActionListener, ItemListener{
     private JLabel lblTanggal,lblNama,lblAlamat,lblTelp,lblNo,lblKeterangan,lblSatuan,lblHarga,lblTotal,lblNo1,lblNo2,lblNo3,lblNo4,lblKg1,lblKg2,lblKg3,lblKg4,lblJumlah,lblUangmuka,lblSisa;
     private JTextField txtNama,txtAlamat,txtTelp,txtSat1,txtSat2,txtSat3,txtSat4,txtHarga1,txtHarga2,txtHarga3,txtHarga4,txtTotal1,txtTotal2,txtTotal3,txtTotal4,txtJml,txtUangmuka,txtSisa;
     private JComboBox cmbTanggal,cmbBulan,cmbTahun,cmbKet1,cmbKet2,cmbKet3,cmbKet4;
     private JCheckBox cbxTotal1,cbxTotal2,cbxTotal3,cbxTotal4;
     private JButton btnTotal, btnSisa, btnReset;

     public NewMain (){
         setTitle("FORM PEMBAYARAN LOUNDRY");
         setSize(700,550);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setLayout(null);
 
         lblTanggal = new JLabel("Tanggal");
         lblNama = new JLabel("Nama");
         lblAlamat = new JLabel("Alamat");
         lblTelp = new JLabel("Telp.");
         lblNo = new JLabel("NO");
         lblNo1 = new JLabel("1");
         lblNo2 = new JLabel("2");
         lblNo3 = new JLabel("3");
         lblNo4 = new JLabel("4");
         lblKg1 = new JLabel(" Kg");
         lblKg2 = new JLabel(" Kg");
         lblKg3 = new JLabel(" Kg");
         lblKg4 = new JLabel(" Kg");
         lblKeterangan = new JLabel("Keterangan");
         lblSatuan = new JLabel("Satuan");
         lblHarga = new JLabel("Harga / Kg");
         lblTotal = new JLabel("Total");
         lblJumlah = new JLabel("Jumlah");
         lblUangmuka = new JLabel("Uang Muka");
         lblSisa = new JLabel("Sisa Bayar");
         String [] tanggal ={"","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
         String [] bulan ={"","01","02","03","04","05","06","07","08","09","10","11","12"};
         String [] tahun ={"","2011","2012","2013","2014","2015","2016","2017","2018","2009","2020"};
         String[] ket1 = {"","Komplit (cuci +  setrika)","Cuci+Kering","Setrika","Cepat komplit (6 jam selesai)"};
         String[] ket2 = {"","Komplit (cuci + setrika)","Cuci+Kering","Setrika","Cepat komplit (6 jam selesai)"};
         String[] ket3 = {"","Komplit (cuci + setrika)","Cuci+Kering","Setrika","Cepat komplit (6 jam selesai)"};
         String[] ket4 = {"","Komplit (cuci + setrika)","Cuci+Kering","Setrika","Cepat komplit (6 jam selesai)"};
         cmbTanggal = new JComboBox(tanggal);
         cmbBulan = new JComboBox(bulan);
         cmbTahun = new JComboBox(tahun);
         cmbKet1 = new JComboBox(ket1);
         cmbKet2 = new JComboBox(ket2);
         cmbKet3 = new JComboBox(ket3);
         cmbKet4 = new JComboBox(ket4);
         txtNama = new JTextField("");
         txtAlamat = new JTextField("");
         txtTelp = new JTextField("");
         txtSat1 = new JTextField("");
         txtSat2 = new JTextField("");
         txtSat3 = new JTextField("");
         txtSat4 = new JTextField("");
         txtHarga1 = new JTextField("");
             txtHarga1.setEditable(false);
         txtHarga2 = new JTextField("");
             txtHarga2.setEditable(false);
         txtHarga3 = new JTextField("");
             txtHarga3.setEditable(false);
         txtHarga4 = new JTextField("");
             txtHarga4.setEditable(false);
         txtTotal1 = new JTextField("0");
             txtTotal1.setEditable(false);
         txtTotal2 = new JTextField("0");
             txtTotal2.setEditable(false);
         txtTotal3 = new JTextField("0");
             txtTotal3.setEditable(false);
         txtTotal4 = new JTextField("0");
             txtTotal4.setEditable(false);
         txtJml = new JTextField("");
             txtJml.setEditable(false);
         txtUangmuka = new JTextField("");
         txtSisa = new JTextField("");
             txtSisa.setEditable(false);
         cbxTotal1 = new JCheckBox();
         cbxTotal2 = new JCheckBox();
         cbxTotal3 = new JCheckBox();
         cbxTotal4 = new JCheckBox();
         btnTotal = new JButton("TOTAL");
         btnSisa = new JButton("SISA BAYAR");
         btnReset = new JButton("RESET");
 
         add(lblTanggal);
         add(lblNama);
         add(lblAlamat);
         add(lblTelp);
         add(lblNo);
         add(lblNo1);
         add(lblNo2);
         add(lblNo3);
         add(lblNo4);
         add(lblKeterangan);
         add(lblSatuan);
         add(lblHarga);
         add(lblTotal);
         add(lblJumlah);
         add(lblUangmuka);
         add(lblSisa);
         add(lblKg1);
         add(lblKg2);
         add(lblKg3);
         add(lblKg4);
         add(txtNama);
         add(txtAlamat);
         add(txtTelp);
         add(txtSat1);
         add(txtSat2);
         add(txtSat3);
         add(txtSat4);
         add(txtHarga1);
         add(txtHarga2);
         add(txtHarga3);
         add(txtHarga4);
         add(txtTotal1);
         add(txtTotal2);
         add(txtTotal3);
         add(txtTotal4);
         add(txtJml);
         add(txtUangmuka);
         add(txtSisa);
         add(cmbTanggal);
         add(cmbBulan);
         add(cmbTahun);
         add(cmbKet1);
         add(cmbKet2);
         add(cmbKet3);
         add(cmbKet4);
         add(cbxTotal1);
         add(cbxTotal2);
         add(cbxTotal3);
         add(cbxTotal4);
         add(btnTotal);
         add(btnSisa);
         add(btnReset);
 
         lblTanggal.setBounds(30,40,150,25);
         lblNama.setBounds(30,70,150,25);
         lblAlamat.setBounds(30,100,150,25);
         lblTelp.setBounds(30,130,150,25);
         lblNo.setBounds(30,180,150,25);
         lblNo1.setBounds(32,210,580,25);
         lblNo2.setBounds(32,240,50,25);
         lblNo3.setBounds(32,270,50,25);
         lblNo4.setBounds(32,300,50,25);
         lblKeterangan.setBounds(120,180,150,25);
         lblSatuan.setBounds(290,180,150,25);
         lblHarga.setBounds(380,180,150,25);
         lblTotal.setBounds(520,180,150,25);
         lblJumlah.setBounds(390,350,100,25);
         lblUangmuka.setBounds(390,380,100,25);
         lblSisa.setBounds(390,410,100,25);
         lblKg1.setBounds(325,210,40,25);
         lblKg2.setBounds(325,240,40,25);
         lblKg3.setBounds(325,270,40,25);
         lblKg4.setBounds(325,300,40,25);
         cmbTanggal.setBounds(100,40,40,20);
         cmbBulan.setBounds(150,40,40,20);
         cmbTahun.setBounds(200,40,55,20);
         cmbKet1.setBounds(60,210,200,25);
         cmbKet2.setBounds(60,240,200,25);
         cmbKet3.setBounds(60,270,200,25);
         cmbKet4.setBounds(60,300,200,25);
         txtNama.setBounds(100,70,200,25);
         txtAlamat.setBounds(100,100,200,25);
         txtTelp.setBounds(100,130,200,25);
         txtSat1.setBounds(280,210,40,25);
         txtSat2.setBounds(280,240,40,25);
         txtSat3.setBounds(280,270,40,25);
         txtSat4.setBounds(280,300,40,25);
         txtHarga1.setBounds(360,210,100,25);
         txtHarga2.setBounds(360,240,100,25);
         txtHarga3.setBounds(360,270,100,25);
         txtHarga4.setBounds(360,300,100,25);
         txtTotal1.setBounds(485,210,100,25);
         txtTotal2.setBounds(485,240,100,25);
         txtTotal3.setBounds(485,270,100,25);
         txtTotal4.setBounds(485,300,100,25);
         txtJml.setBounds(485,350,100,25);
         txtUangmuka.setBounds(485,380,100,25);
         txtSisa.setBounds(485,410,100,25);
         cbxTotal1.setBounds(600,210,100,25);
         cbxTotal2.setBounds(600,240,100,25);
         cbxTotal3.setBounds(600,270,100,25);
         cbxTotal4.setBounds(600,300,100,25);
         btnTotal.setBounds(270,450,100,25);
         btnSisa.setBounds(380,450,110,25);
         btnReset.setBounds(530,450,100,25);
 
 
         cmbKet1.addItemListener(this);
         cmbKet2.addItemListener(this);
         cmbKet3.addItemListener(this);
         cmbKet4.addItemListener(this);
         cbxTotal1.addItemListener(this);
         cbxTotal2.addItemListener(this);
         cbxTotal3.addItemListener(this);
         cbxTotal4.addItemListener(this);
         btnTotal.addActionListener(this);
         btnSisa.addActionListener(this);
         btnReset.addActionListener(this);

         }
  public void actionPerformed(ActionEvent e) {
  Object tombol = e.getSource();
  if(tombol==btnTotal){
          int n1=Integer.parseInt(txtTotal1.getText());
          int n2=Integer.parseInt(txtTotal2.getText());
          int n3=Integer.parseInt(txtTotal3.getText());
          int n4=Integer.parseInt(txtTotal4.getText());
          int hasil=n1+n2+n3+n4;
   
          txtJml.setText(""+hasil);
  }else if(tombol==btnSisa){
          int n3=Integer.parseInt(txtJml.getText());
          int n4=Integer.parseInt(txtUangmuka.getText());
          int akhir=n3-n4;
          txtSisa.setText(""+akhir);
  }else if (tombol==btnReset){
          txtNama.setText("");
          txtAlamat.setText("");
          txtTelp.setText("");
          txtSat1.setText("");
          txtSat2.setText("");
          txtSat3.setText("");
          txtSat4.setText("");
          txtHarga1.setText("");
          txtHarga2.setText("");
          txtHarga3.setText("");
          txtHarga4.setText("");
          txtTotal1.setText("0");
          txtTotal2.setText("0");
          txtTotal3.setText("0");
          txtTotal4.setText("0");
          txtJml.setText("");
          txtUangmuka.setText("");
          txtSisa.setText("");
          cmbTanggal.setSelectedIndex(0);
          cmbBulan.setSelectedIndex(0);
          cmbTahun.setSelectedIndex(0);
          cmbKet1.setSelectedIndex(0);
          cmbKet2.setSelectedIndex(0);
          cmbKet3.setSelectedIndex(0);
          cmbKet4.setSelectedIndex(0);
          cbxTotal1.isSelected();
       }
  }
  public void itemStateChanged(ItemEvent ie){
  Object pil = ie.getSource();
  Object tot = ie.getSource();
  if(tot == cbxTotal1){
       if(cbxTotal1.isSelected()){
           int t1=Integer.parseInt(txtSat1.getText());
           int t2=Integer.parseInt(txtHarga1.getText());
           int total=t1*t2;
           txtTotal1.setText(""+total);
      }
   }
  if(tot == cbxTotal2){
       if(cbxTotal2.isSelected()){
           int t1=Integer.parseInt(txtSat2.getText());
           int t2=Integer.parseInt(txtHarga2.getText());
           int total=t1*t2;
           txtTotal2.setText(""+total);
       }
   }
  if(tot == cbxTotal3){
       if(cbxTotal3.isSelected()){
           int t1=Integer.parseInt(txtSat3.getText());
           int t2=Integer.parseInt(txtHarga3.getText());
           int total=t1*t2;
           txtTotal3.setText(""+total);
       }
   }
  if(tot == cbxTotal4){
       if(cbxTotal4.isSelected()){
           int t1=Integer.parseInt(txtSat4.getText());
           int t2=Integer.parseInt(txtHarga4.getText());
           int total=t1*t2;
           txtTotal4.setText(""+total);
      }
   }
  if(pil == cmbKet1){
       if(cmbKet1.getSelectedIndex()==0){
           txtHarga1.setText("");
       }else if(cmbKet1.getSelectedIndex()==1){
           txtHarga1.setText("3000");
       }else if(cmbKet1.getSelectedIndex()==2){
           txtHarga1.setText("2500");
       }else if(cmbKet1.getSelectedIndex()==3){
           txtHarga1.setText("2000");
       }else if(cmbKet1.getSelectedIndex()==4){
           txtHarga1.setText("6000");
       }
  }
  if(pil == cmbKet2){
       if(cmbKet2.getSelectedIndex()==0){
           txtHarga2.setText("");
       }else if(cmbKet2.getSelectedIndex()==1){
           txtHarga2.setText("3000");
       }else if(cmbKet2.getSelectedIndex()==2){
           txtHarga2.setText("2500");
       }else if(cmbKet2.getSelectedIndex()==3){
           txtHarga2.setText("2000");
       }else if(cmbKet2.getSelectedIndex()==4){
           txtHarga2.setText("6000");
      }
  }
 
  if(pil == cmbKet3){
       if(cmbKet3.getSelectedIndex()==0){
           txtHarga3.setText("");
       }else if(cmbKet3.getSelectedIndex()==1){
           txtHarga3.setText("3000");
       }else if(cmbKet3.getSelectedIndex()==2){
           txtHarga3.setText("2500");
       }else if(cmbKet3.getSelectedIndex()==3){
           txtHarga3.setText("2000");
       }else if(cmbKet3.getSelectedIndex()==4){
           txtHarga3.setText("6000");
       }
  }
 
  if(pil == cmbKet4){
       if(cmbKet4.getSelectedIndex()==0){
           txtHarga4.setText("");
       }else if(cmbKet4.getSelectedIndex()==1){
           txtHarga4.setText("3000");
 
       }else if(cmbKet4.getSelectedIndex()==2){
           txtHarga4.setText("2500");
       }else if(cmbKet4.getSelectedIndex()==3){
           txtHarga4.setText("2000");
       }else if(cmbKet4.getSelectedIndex()==4){
           txtHarga4.setText("6000");
       }
    }
 }public static void main (String args[]){
      NewMain lndry = new NewMain ();
      lndry.setVisible(true);
   }
}

Nih Lihat Output Running-nya.



SELAMAT MENCOBA...!!