You are on page 1of 3

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

java * * Created on 16 Des 12, 10:05:48 */ package inputnilai.proses; /** * * @author FTIK */ public class Gui extends javax.swing.JFrame { int input; String nilai; /** Creates new form Gui */ public Gui() { 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">//GEN-BEGIN:i nitComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); text1 = new javax.swing.JTextField(); text2 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText("Input"); jLabel2.setText("Nilai"); jButton1.setText("Proses"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Clear"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); }

}); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentP ane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING ) .addGroup(layout.createSequentialGroup() .addGap(48, 48, 48) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) .addGap(38, 38, 38) .addComponent(jButton2)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2)) .addGap(100, 100, 100) .addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING, false) .addComponent(text2) .addComponent(text1, javax.swing.GroupLayout.DEFAULT _SIZE, 84, Short.MAX_VALUE)))) .addContainerGap(142, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING ) .addGroup(layout.createSequentialGroup() .addGap(36, 36, 36) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.BASELINE) .addComponent(jLabel1) .addComponent(text1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.BASELINE) .addComponent(jLabel2) .addComponent(text2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(32, 32, 32) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali gnment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addContainerGap(140, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed // TODO add your handling code here: input=Integer.parseInt(text1.getText());

if((input>=85)&&(input<=100)) { nilai="A"; } else { nilai ="A"; } if((input>=70)&&(input<=84)) { nilai ="B"; } else if((input>=55)&&(input<=69)) { nilai ="C"; } else if((input>=0)&&(input<=54)) { nilai ="D"; } text2.setText(String.valueOf(nilai)); }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton2ActionPerformed // TODO add your handling code here: text1.setText(""); text2.setText(""); }//GEN-LAST:event_jButton2ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Gui().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JTextField text1; private javax.swing.JTextField text2; // End of variables declaration//GEN-END:variables }

You might also like