Jumat, 22 Maret 2013
MEMBUAT APLIKASI MENENTUKAN HARGA SERTA PEMBAYARAN DAN MENCARI JENIS PIZZA


Membuat Grup Radio Button
Ambil Button Group dari Palette (Swing Controls) Lalu Drag kea rah panel yang tersedia Radio Button


Listing Program
LISTING MEMUNCULKAN HARGA PADA JPANEL EXTRA.
    private void jr1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        eks1.setText("8000");
    }

    private void jr2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         eks1.setText("5000");
    }

    private void jr3ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
         eks1.setText("4000");
    }
LISTING MENGHITUNG TOTAL BAYAR
    private void j1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        int hrg1=Integer.parseInt(e.getText());
        int hrg2=Integer.parseInt(i.getText());
        int jbl=hrg1*hrg2;
        int hrg3=Integer.parseInt(eks1.getText());
        int toba=jbl+hrg3;
        String tb=Integer.toString(toba);
        f.setText(tb);
    }
LISTING UNTUK MENENTUKAN NAMA DAN HARGA PIZZA DENGAN PILIHAN KODE TOPPING DAN KODE UKURAN
LISTING DISIMPAN DALAM “COMBO BOX KODE UKURAN”
    private void cActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
             if(b.getSelectedItem().equals("T001")){
            d.setText("meat lovers");
            if(c.getSelectedItem().equals("kecil")){
                e.setText("25000");
            }
            else if(c.getSelectedItem().equals("sedang")){
                e.setText("27000");
            }
            else if(c.getSelectedItem().equals("besar")){
                e.setText("30000");
            }

        }
        else if(b.getSelectedItem().equals("T002"))
        {
            d.setText("meat Beeft");
            if(c.getSelectedItem().equals("kecil")){
                e.setText("27000");
            }
            else if(c.getSelectedItem().equals("sedang")){
                e.setText("29000");
            }
            else if(c.getSelectedItem().equals("besar")){
                e.setText("32000");
            }

        }
        else if(b.getSelectedItem().equals("T003"))
        {
            d.setText("meat lovers");
            if(c.getSelectedItem().equals("kecil")){
                e.setText("28000");
            }
            else if(c.getSelectedItem().equals("sedang")){
                e.setText("33000");
            }
            else if(c.getSelectedItem().equals("besar")){
                e.setText("37000");
            }

        }
    }
LISTING “BUTTON BERSIH”
    private void j2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        a.setText("");
        d.setText("");
        e.setText("");
        f.setText("");
        g.setText("");
        h.setText("");
        i.setText("");
        eks1.setText("");

    }
LISTING EXIT DENGAN MENGGUNAKAN MESSAGE BOX
    private void j3ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        Int reply=JOptionPane.showConfirmDialog(null, “Lho, yakin mau keluar?”,”Konfirmasi Keluar Aplikasi”,JOptionPane.YES_NO_OPTION);
If(reply==JOptionPane.YES_OPTION){      
        System.exit(0);
               }else{
    a.requestFocus();
               }
    }

LISTING MENGHITUNG UANG KEMBALI
LISTING DILETAKKAN PADA “TEXTFIELD Uang BAYAR” 
  private void gActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        int n1=Integer.parseInt(f.getText());
        int n2=Integer.parseInt(g.getText());
        int hsl=n2-n1;
        String hasil=Integer.toString(hsl);
        h.setText(hasil);
       
    }