12/29/11

Object Oriented Java Programing Part I

Java Swing  jButton, jRadioButton and jTextField with NetBean
 
This app version indonesia language... you can tray and change language with your language. These applications use the java programming language,... 

Script:
public class hitung extends javax.swing.JFrame {
    public hitung() {
        initComponents();
    }

private void jHitungActionPerformed(java.awt.event.ActionEvent evt)               {                                       
        String a = Textnil1.getText();
        String b = Textnil2.getText();

      if(BtTambah.isSelected()){
        Float L = Float.parseFloat(a)+Float.parseFloat(b);
        jHasil.setText("Hasil : " + L);
      }                                       
      if(BtKali.isSelected()){
        Float L = Float.parseFloat(a)*Float.parseFloat(b);
        jHasil.setText("Hasil : " + L);
      }
      if(BtKurang.isSelected()){
        Float L = Float.parseFloat(a)-Float.parseFloat(b);
        jHasil.setText("Hasil : " + L);
      }
      if(BtBagi.isSelected()){
        Float L = Float.parseFloat(a)/Float.parseFloat(b);
        jHasil.setText("Hasil : " + L);
    }
}
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new hitung().setVisible(true);
            }
        });
    }
    private javax.swing.JRadioButton BtBagi;
    private javax.swing.JRadioButton BtKali;
    private javax.swing.JRadioButton BtKurang;
    private javax.swing.JRadioButton BtTambah;
    private javax.swing.ButtonGroup BtnGrup;
    private javax.swing.JTextField Textnil1;
    private javax.swing.JLabel jHasil;
    private javax.swing.JButton jHitung;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
}

Output Runing Program: