Tentang algoritma matematika segiempat
code
/** To change this template, choose Tools | Templates* and open the template in the editor.*/package tugasjava1;/**** @author acer*/public class algoritMtk extends javax.swing.JFrame {/*** Creates new form algoritMtk*/public algoritMtk() {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() {jTextField1 = new javax.swing.JTextField();jLabel1 = new javax.swing.JLabel();jLabel2 = new javax.swing.JLabel();jLabel3 = new javax.swing.JLabel();jLabel4 = new javax.swing.JLabel();txtPanjang = new javax.swing.JTextField();txtLebar = new javax.swing.JTextField();txtTinggi = new javax.swing.JTextField();txtHasil = new javax.swing.JTextField();BtnHitung = new javax.swing.JButton();BtnMulai = new javax.swing.JButton();BtnLuas = new javax.swing.JButton();BtnVolume = new javax.swing.JButton();jTextField1.setText("jTextField1");setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);jLabel1.setText("Panjang");jLabel2.setText("Lebar");jLabel3.setText("Tinggi");jLabel4.setText("Hasil");txtPanjang.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {txtPanjangActionPerformed(evt);}});txtLebar.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {txtLebarActionPerformed(evt);}});txtTinggi.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {txtTinggiActionPerformed(evt);}});txtHasil.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {txtHasilActionPerformed(evt);}});BtnHitung.setText("Hitung");BtnHitung.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {BtnHitungActionPerformed(evt);}});BtnMulai.setText("Mulai");BtnMulai.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {BtnMulaiActionPerformed(evt);}});BtnLuas.setText("Luas");BtnLuas.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {BtnLuasActionPerformed(evt);}});BtnVolume.setText("Volume");BtnVolume.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {BtnVolumeActionPerformed(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().addGap(24, 24, 24).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGap(40, 40, 40)).addGroup(layout.createSequentialGroup().addComponent(jLabel3).addGap(51, 51, 51))).addGroup(layout.createSequentialGroup().addComponent(jLabel4).addGap(57, 57, 57))).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false).addComponent(txtPanjang, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE).addComponent(txtLebar).addComponent(txtTinggi, javax.swing.GroupLayout.Alignment.LEADING).addComponent(txtHasil, javax.swing.GroupLayout.Alignment.LEADING)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(BtnVolume, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(BtnLuas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGap(56, 56, 56)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(92, Short.MAX_VALUE).addComponent(BtnMulai, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(58, 58, 58).addComponent(BtnHitung, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(93, 93, 93)));layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(25, 25, 25).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(txtPanjang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(18, 18, 18).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(txtLebar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(18, 18, 18).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel3).addComponent(txtTinggi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(18, 18, 18).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel4).addComponent(txtHasil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))).addGroup(layout.createSequentialGroup().addGap(46, 46, 46).addComponent(BtnLuas).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(BtnVolume))).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(BtnHitung).addComponent(BtnMulai)).addGap(76, 76, 76)));pack();}// </editor-fold>private void txtPanjangActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:txtPanjang.setText("");}private void txtLebarActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:txtLebar.setText("");}private void BtnHitungActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here}private void txtTinggiActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:txtTinggi.setText("");}private void BtnMulaiActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:txtPanjang.setText("");txtLebar.setText("");txtTinggi.setText("");txtHasil.setText("");}private void txtHasilActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:txtHasil.setText(""+Hasil);}private void BtnLuasActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:int P = Integer.parseInt(txtPanjang.getText());int L = Integer.parseInt(txtLebar.getText());int Hasil = P*L;txtHasil.setText(""+Hasil);}private void BtnVolumeActionPerformed(java.awt.event.ActionEvent evt) {// TODO add your handling code here:int P = Integer.parseInt(txtPanjang.getText());int L = Integer.parseInt(txtLebar.getText());int T = Integer.parseInt(txtTinggi.getText());int Hasil = P*L*T;txtHasil.setText(""+Hasil);txtHasil.setText(""+Hasil);}/*** @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(algoritMtk.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);} catch (InstantiationException ex) {java.util.logging.Logger.getLogger(algoritMtk.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);} catch (IllegalAccessException ex) {java.util.logging.Logger.getLogger(algoritMtk.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);} catch (javax.swing.UnsupportedLookAndFeelException ex) {java.util.logging.Logger.getLogger(algoritMtk.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 algoritMtk().setVisible(true);}});}// Variables declaration - do not modifyprivate javax.swing.JButton BtnHitung;private javax.swing.JButton BtnLuas;private javax.swing.JButton BtnMulai;private javax.swing.JButton BtnVolume;private javax.swing.JLabel jLabel1;private javax.swing.JLabel jLabel2;private javax.swing.JLabel jLabel3;private javax.swing.JLabel jLabel4;private javax.swing.JTextField jTextField1;private javax.swing.JTextField txtHasil;private javax.swing.JTextField txtLebar;private javax.swing.JTextField txtPanjang;private javax.swing.JTextField txtTinggi;// End of variables declaration}
Tidak ada komentar:
Posting Komentar