Selasa, 24 April 2012

JAVA_TUGAS


/*
 * Tugas.java
 *
 * Created on 21 April 2012, 13:42
 */
/**
 *
 * @author  Ferdinand
 */
public class Tugas extends javax.swing.JFrame {
    int HARGA,JOG, SWI, GYM, BANK, TOTAL, KODEFS;
    /** Creates new form Tugas */
    public Tugas() {
        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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
        bbayar = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        CMBLOKASI = new javax.swing.JComboBox();
        tharga = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        CJ = new javax.swing.JCheckBox();
        CS = new javax.swing.JCheckBox();
        CG = new javax.swing.JCheckBox();
        tjogging = new javax.swing.JTextField();
        tswimming = new javax.swing.JTextField();
        tgym = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        RBRI = new javax.swing.JRadioButton();
        ROTHER = new javax.swing.JRadioButton();
        tbank = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        ttotal = new javax.swing.JTextField();
        BNEW = new javax.swing.JButton();
        BCLOSE = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Tugas Java");
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Data Rumah", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        jPanel1.setForeground(new java.awt.Color(102, 255, 51));
        jLabel1.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 51, 51));
        jLabel1.setText("LOKASI");
        jLabel2.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 51, 51));
        jLabel2.setText("HARGA DASAR");
        CMBLOKASI.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        CMBLOKASI.setForeground(new java.awt.Color(255, 51, 51));
        CMBLOKASI.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PILIH", "BLOK A", "BLOK B", "BLOK C" }));
        CMBLOKASI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CMBLOKASIActionPerformed(evt);
            }
        });
        tharga.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tharga.setForeground(new java.awt.Color(51, 255, 51));
        tharga.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                thargaActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(45, 45, 45)
                        .addComponent(CMBLOKASI, 0, 179, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tharga, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(CMBLOKASI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tharga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Fasilitas Rumah", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        jPanel2.setForeground(new java.awt.Color(102, 255, 51));
        CJ.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        CJ.setForeground(new java.awt.Color(255, 51, 51));
        CJ.setText("JOGGING TRACK");
        CJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CJActionPerformed(evt);
            }
        });
        CS.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        CS.setForeground(new java.awt.Color(255, 51, 51));
        CS.setText("SWIMMING POOL");
        CS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CSActionPerformed(evt);
            }
        });
        CG.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        CG.setForeground(new java.awt.Color(255, 51, 51));
        CG.setText("GYMNASIUM");
        CG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CGActionPerformed(evt);
            }
        });
        tjogging.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tjogging.setForeground(new java.awt.Color(51, 255, 51));
        tswimming.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tswimming.setForeground(new java.awt.Color(51, 255, 51));
        tgym.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tgym.setForeground(new java.awt.Color(51, 255, 51));
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(CJ)
                    .addComponent(CG)
                    .addComponent(CS))
                .addGap(6, 6, 6)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tgym, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                    .addComponent(tjogging, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                    .addComponent(tswimming, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CJ)
                    .addComponent(tjogging, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CS)
                    .addComponent(tswimming, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tgym, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CG))
                .addContainerGap())
        );
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Cara Pembayaran", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        bbayar.add(RBRI);
        RBRI.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        RBRI.setForeground(new java.awt.Color(255, 51, 51));
        RBRI.setText("BANK RAKYAT INDONESIA");
        RBRI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBRIActionPerformed(evt);
            }
        });

        bbayar.add(ROTHER);
        ROTHER.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
        ROTHER.setForeground(new java.awt.Color(255, 51, 51));
        ROTHER.setText("OTHER BANK");
        ROTHER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ROTHERActionPerformed(evt);
            }
        });

        tbank.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        tbank.setForeground(new java.awt.Color(51, 255, 51));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ROTHER)
                    .addComponent(RBRI))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(tbank, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(RBRI)
                .addGap(33, 33, 33))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(30, Short.MAX_VALUE)
                .addComponent(ROTHER)
                .addContainerGap())
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tbank, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jLabel3.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 51, 51));
        jLabel3.setText("TOTAL HARGA");
        ttotal.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        ttotal.setForeground(new java.awt.Color(51, 255, 51));
        BNEW.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N
        BNEW.setForeground(new java.awt.Color(0, 0, 255));
        BNEW.setText("NEW");
        BNEW.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNEWActionPerformed(evt);
            }
        });
        BCLOSE.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N
        BCLOSE.setForeground(new java.awt.Color(0, 0, 255));
        BCLOSE.setText("CLOSE");
        BCLOSE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCLOSEActionPerformed(evt);
            }
        });
        jLabel4.setFont(new java.awt.Font("Arial Black", 1, 24)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(51, 51, 255));
        jLabel4.setText("PENJULAN RUMAH PT. DAMSUR88");
        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(141, 141, 141)
                .addComponent(BNEW, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41)
                .addComponent(BCLOSE, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(273, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(298, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(jLabel4)
                .addContainerGap(133, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(188, Short.MAX_VALUE)
                .addComponent(ttotal, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(375, 375, 375))
            .addGroup(layout.createSequentialGroup()
                .addGap(198, 198, 198)
                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(376, 376, 376))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(23, 23, 23)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(13, 13, 13)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ttotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BCLOSE, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BNEW, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22))
        );
        pack();
    }// </editor-fold>
void TOTAL()
{
    TOTAL=HARGA+JOG+SWI+GYM+BANK;
    ttotal.setText(String.valueOf(TOTAL));
}

    private void CMBLOKASIActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        KODEFS=CMBLOKASI.getSelectedIndex();
        switch(KODEFS)
        {
            case 1:
                HARGA=2000000;
            break;
           
            case 2:
                HARGA=3000000;
            break;
             case 3:
                 HARGA=4000000;
            break;
            default:
                HARGA=0;
        }
        tharga.setText(String.valueOf(HARGA));   
 TOTAL();
}                                        
    private void CSActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        if (CS.isSelected()==true)
            SWI=200000;
        else
            SWI=0;
        tswimming.setText(String.valueOf(SWI));
       
 TOTAL();
}                                 
    private void CGActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        if (CG.isSelected()==true)
            GYM=300000;
        else
            GYM=0;
        tgym.setText(String.valueOf(GYM));      
 TOTAL();
}                                 
    private void thargaActionPerformed(java.awt.event.ActionEvent evt) {                                       
       // TODO add your handling code here:
}                                     
   private void CJActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        if (CJ.isSelected()==true)
        JOG=100000;
    else
        JOG=0;
    tjogging.setText(String.valueOf(JOG));
 TOTAL();
    }                                 

    private void BNEWActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        CMBLOKASI.setSelectedIndex(0);
        tharga.setText("");
        tbank.setText("");
        ttotal.setText("");
        tgym.setText("");
        tjogging.setText("");
        tswimming.setText("");
        bbayar.clearSelection();
        CJ.setSelected(false);
        CS.setSelected(false);
        CG.setSelected(false);
    }                                      
    private void BCLOSEActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
       System.exit(0);
    }                                      
    private void RBRIActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        BANK=10000;
        tbank.setText(String.valueOf(BANK));
 TOTAL();
    }                                  
    private void ROTHERActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        BANK=50000;
        tbank.setText(String.valueOf(BANK));
 TOTAL();
    }                                  
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Tugas().setVisible(true);
            }
        });
    }
   
    // Variables declaration - do not modify
    private javax.swing.JButton BCLOSE;
    private javax.swing.JButton BNEW;
    private javax.swing.JCheckBox CG;
    private javax.swing.JCheckBox CJ;
    private javax.swing.JComboBox CMBLOKASI;
    private javax.swing.JCheckBox CS;
    private javax.swing.JRadioButton RBRI;
    private javax.swing.JRadioButton ROTHER;
    private javax.swing.ButtonGroup bbayar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField tbank;
    private javax.swing.JTextField tgym;
    private javax.swing.JTextField tharga;
    private javax.swing.JTextField tjogging;
    private javax.swing.JTextField tswimming;
    private javax.swing.JTextField ttotal;
    // End of variables declaration
   
}