Project application to calculate area of ​​a circle


Use netbeans to create software applications such as image above.
The first thing is to make sure your new project and put this script in netbeans your editing software.

Netbeans application to calculate area of ​​a circle.



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/*
 * LuasLingkaran.java
 *
 * Created on Oct 27, 2011, 12:01:11 PM
 */
/**
 *
 * @author VHEROLLY__http://netbeansexercise.blogspot.com__
 */
import javax.swing.JOptionPane;
public class LuasLingkaran extends javax.swing.JFrame {
    /** Creates new form LuasLingkaran */
    public LuasLingkaran() {
        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")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {


        jLayeredPane1 = new javax.swing.JLayeredPane();
        jTextField3 = new javax.swing.JTextField();
        bTambah = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        jTextField1 = new javax.swing.JTextField();
        tfMasuk1 = new javax.swing.JTextField();
        tfMasuk2 = new javax.swing.JTextField();
        jHapus = new javax.swing.JButton();
        tfHasil = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();


        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);


        jTextField3.setBackground(new java.awt.Color(51, 51, 255));
        jTextField3.setEditable(false);
        jTextField3.setFont(new java.awt.Font("Tahoma", 1, 14));
        jTextField3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField3.setText("Area of Circle");
        jTextField3.setBounds(50, 20, 290, 30);
        jLayeredPane1.add(jTextField3, javax.swing.JLayeredPane.DEFAULT_LAYER);


        bTambah.setText("Results");
        bTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bTambahActionPerformed(evt);
            }
        });
        bTambah.setBounds(70, 210, 80, 30);
        jLayeredPane1.add(bTambah, javax.swing.JLayeredPane.DEFAULT_LAYER);


        jTextField2.setEditable(false);
        jTextField2.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField2.setText("Formula :");
        jTextField2.setBounds(20, 130, 130, 30);
        jLayeredPane1.add(jTextField2, javax.swing.JLayeredPane.DEFAULT_LAYER);


        jTextField1.setEditable(false);
        jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField1.setText("Radius Circle :");
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        jTextField1.setBounds(20, 90, 130, 30);
        jLayeredPane1.add(jTextField1, javax.swing.JLayeredPane.DEFAULT_LAYER);








        tfMasuk1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfMasuk1.setBounds(160, 90, 110, 30);
        jLayeredPane1.add(tfMasuk1, javax.swing.JLayeredPane.DEFAULT_LAYER);


        tfMasuk2.setEditable(false);
        tfMasuk2.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfMasuk2.setText("3.14");
        tfMasuk2.setBounds(160, 130, 110, 30);
        jLayeredPane1.add(tfMasuk2, javax.swing.JLayeredPane.DEFAULT_LAYER);


        jHapus.setText("Clear");
        jHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jHapusActionPerformed(evt);
            }
        });
        jHapus.setBounds(200, 210, 70, 30);
        jLayeredPane1.add(jHapus, javax.swing.JLayeredPane.DEFAULT_LAYER);


        tfHasil.setFont(new java.awt.Font("Tahoma", 1, 11));
        tfHasil.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfHasil.setBounds(160, 170, 110, 30);
        jLayeredPane1.add(tfHasil, javax.swing.JLayeredPane.DEFAULT_LAYER);


        jTextField4.setEditable(false);
        jTextField4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jTextField4.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField4.setText("Results :");
        jTextField4.setBounds(80, 170, 70, 30);
        jLayeredPane1.add(jTextField4, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jLabel1.setBounds(0, -10, 410, 280);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);


        jTextField5.setEditable(false);
        jTextField5.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jTextField5.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField5.setText("http://netbeansexercise.blogspot.com");
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(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()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(191, Short.MAX_VALUE)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );


        pack();
    }// </editor-fold>


private void bTambahActionPerformed(java.awt.event.ActionEvent evt) {                                        
// TODO add your handling code here:
    int totalHarga = 0;


if(!tfMasuk1.getText().equalsIgnoreCase("")){
totalHarga+=Integer.parseInt(tfMasuk1.getText())* Integer.parseInt(tfMasuk1.getText())* 3.14;
}else
JOptionPane.showMessageDialog(null,"Maaf silahkan masukkan jari-jari lingkaran","Error", JOptionPane.ERROR_MESSAGE);


tfHasil.setText(""+totalHarga);
}                                       


private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
// TODO add your handling code here:
}                                           


private void jHapusActionPerformed(java.awt.event.ActionEvent evt) {                                       
// TODO add your handling code here:
    tfMasuk1.setText("");
    tfHasil.setText("");
}                                      


private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}


    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* 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(LuasLingkaran.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(LuasLingkaran.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(LuasLingkaran.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(LuasLingkaran.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>


        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {


            public void run() {
                new LuasLingkaran().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton bTambah;
    private javax.swing.JButton jHapus;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField tfHasil;
    private javax.swing.JTextField tfMasuk1;
    private javax.swing.JTextField tfMasuk2;
    // End of variables declaration
}


Downnload free script.

Download here (via mediafire)

Comments :

0 komentar to “Project application to calculate area of ​​a circle”

Posting Komentar

Advertisement:

Blog :