CONTOH PROGRAM NETBEANS 8.2 YANG SUDAH RUN
/*
* To change this license header, choose
License Headers in Project Properties.
* To change this template file, choose Tools |
Templates
* and open the template in the editor.
*/
/**
*
* @author herdiansyah
*/
public
class quis extends javax.swing.JFrame {
private void proses()
{
Double
a,t,uts,uas,NA;
a =
Double.parseDouble(tx_absen.getText());
t
=Double.parseDouble(tx_tugas.getText());
uas
= Double.parseDouble (tx_uas.getText());
uts =
Double.parseDouble(tx_uts.getText());
NA
= (a+t+uts+ uas )/ 4 ;
tx_akhir.setText(String.valueOf(NA));
}
private void ulangi ()
{
tx_nama.setText("");
tx_nim.setText("");
tx_absen.setText("");
tx_tugas.setText("");
tx_uts.setText("");
tx_uas.setText("");
tx_akhir.setText("");
tx_nama.requestFocus();
}
/**
* Creates new form quis
*/
public quis() {
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() {
jPanel1 = new javax.swing.JPanel();
tx_nama = new javax.swing.JPanel();
tx_nim = new javax.swing.JPanel();
tx_absen = new javax.swing.JPanel();
tx_tugas = new javax.swing.JPanel();
tx_uas = new javax.swing.JPanel();
tx_uts = new javax.swing.JPanel();
tx_akhir = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new
java.awt.Color(0, 102, 102));
javax.swing.GroupLayout tx_namaLayout =
new javax.swing.GroupLayout(tx_nama);
tx_nama.setLayout(tx_namaLayout);
tx_namaLayout.setHorizontalGroup(
tx_namaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
tx_namaLayout.setVerticalGroup(
tx_namaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 22, Short.MAX_VALUE)
);
javax.swing.GroupLayout tx_nimLayout =
new javax.swing.GroupLayout(tx_nim);
tx_nim.setLayout(tx_nimLayout);
tx_nimLayout.setHorizontalGroup(
tx_nimLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
tx_nimLayout.setVerticalGroup(
tx_nimLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 18, Short.MAX_VALUE)
);
javax.swing.GroupLayout tx_absenLayout
= new javax.swing.GroupLayout(tx_absen);
tx_absen.setLayout(tx_absenLayout);
tx_absenLayout.setHorizontalGroup(
tx_absenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
tx_absenLayout.setVerticalGroup(
tx_absenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 23, Short.MAX_VALUE)
);
javax.swing.GroupLayout tx_tugasLayout
= new javax.swing.GroupLayout(tx_tugas);
tx_tugas.setLayout(tx_tugasLayout);
tx_tugasLayout.setHorizontalGroup(
tx_tugasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
tx_tugasLayout.setVerticalGroup(
tx_tugasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 21, Short.MAX_VALUE)
);
javax.swing.GroupLayout tx_uasLayout =
new javax.swing.GroupLayout(tx_uas);
tx_uas.setLayout(tx_uasLayout);
tx_uasLayout.setHorizontalGroup(
tx_uasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
tx_uasLayout.setVerticalGroup(
tx_uasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 24, Short.MAX_VALUE)
);
javax.swing.GroupLayout tx_utsLayout =
new javax.swing.GroupLayout(tx_uts);
tx_uts.setLayout(tx_utsLayout);
tx_utsLayout.setHorizontalGroup(
tx_utsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
tx_utsLayout.setVerticalGroup(
tx_utsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 21, Short.MAX_VALUE)
);
javax.swing.GroupLayout tx_akhirLayout
= new javax.swing.GroupLayout(tx_akhir);
tx_akhir.setLayout(tx_akhirLayout);
tx_akhirLayout.setHorizontalGroup(
tx_akhirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 229, Short.MAX_VALUE)
);
tx_akhirLayout.setVerticalGroup(
tx_akhirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 24, Short.MAX_VALUE)
);
jLabel1.setText("nama");
jLabel2.setText("nim");
jLabel3.setText("absen");
jLabel4.setText("tugas");
jLabel5.setText("uas");
jLabel6.setText("uts");
jLabel7.setText("nilai
akhir");
jButton1.setText("proses");
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("ulangi");
jButton2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(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()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(65, 65,
65)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(25, 25,
25))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel7)
.addGap(18, 18,
18)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(tx_akhir, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tx_uts, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tx_uas, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tx_tugas,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(tx_absen, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tx_nim, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tx_nama, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(139, 139, 139)
.addComponent(jButton1)
.addGap(51, 51, 51)
.addComponent(jButton2)))
.addContainerGap(52,
Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tx_nama,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18,
18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tx_nim, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addComponent(tx_absen, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(tx_tugas, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(tx_uas,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel5))
.addGap(18, 18, 18)
.addComponent(tx_uts,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel6))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(tx_akhir,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(50, 50, 50))
);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
proses
(); // TODO add your handling code
here:
}
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
ulangi
(); // 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(quis.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(quis.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(quis.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(quis.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 quis().setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel tx_absen;
private javax.swing.JPanel tx_akhir;
private javax.swing.JPanel tx_nama;
private javax.swing.JPanel tx_nim;
private javax.swing.JPanel tx_tugas;
private javax.swing.JPanel tx_uas;
private javax.swing.JPanel tx_uts;
// End of variables declaration
}
Comments
Post a Comment