You are on page 1of 18

package pbo;

import javax.swing.JOptionPane;

public class NilaiMahasiswa extends javax.swing.JFrame {

public NilaiMahasiswa() {

initComponents();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents

private void initComponents() {

jFrame1 = new javax.swing.JFrame();

jFrame2 = new javax.swing.JFrame();

jFrame3 = new javax.swing.JFrame();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

textNama = new javax.swing.JTextField();

textNIM = new javax.swing.JTextField();

textAbsen = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();


jLabel7 = new javax.swing.JLabel();

textTugas = new javax.swing.JTextField();

textUTS = new javax.swing.JTextField();

textUAS = new javax.swing.JTextField();

tombolHitung = new javax.swing.JButton();

jLabel8 = new javax.swing.JLabel();

javax.swing.GroupLayout jFrame1Layout = new


javax.swing.GroupLayout(jFrame1.getContentPane());

jFrame1.getContentPane().setLayout(jFrame1Layout);

jFrame1Layout.setHorizontalGroup(

jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 400, Short.MAX_VALUE)

);

jFrame1Layout.setVerticalGroup(

jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 300, Short.MAX_VALUE)

);

javax.swing.GroupLayout jFrame2Layout = new


javax.swing.GroupLayout(jFrame2.getContentPane());

jFrame2.getContentPane().setLayout(jFrame2Layout);

jFrame2Layout.setHorizontalGroup(

jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 400, Short.MAX_VALUE)

);
jFrame2Layout.setVerticalGroup(

jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 300, Short.MAX_VALUE)

);

javax.swing.GroupLayout jFrame3Layout = new


javax.swing.GroupLayout(jFrame3.getContentPane());

jFrame3.getContentPane().setLayout(jFrame3Layout);

jFrame3Layout.setHorizontalGroup(

jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 400, Short.MAX_VALUE)

);

jFrame3Layout.setVerticalGroup(

jFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 300, Short.MAX_VALUE)

);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

jLabel1.setText("Nama");

jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

jLabel2.setText("NIM");

jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N


jLabel3.setText("Absen");

textNama.addContainerListener(new java.awt.event.ContainerAdapter() {

public void componentAdded(java.awt.event.ContainerEvent evt) {

textNamaComponentAdded(evt);

});

textNama.addAncestorListener(new javax.swing.event.AncestorListener() {

public void ancestorAdded(javax.swing.event.AncestorEvent evt) {

public void ancestorMoved(javax.swing.event.AncestorEvent evt) {

textNamaAncestorMoved(evt);

public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {

});

textNama.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

textNamaMouseClicked(evt);

});

textNama.addComponentListener(new java.awt.event.ComponentAdapter() {

public void componentMoved(java.awt.event.ComponentEvent evt) {

jTextPane1(evt);

}
});

textNama.addInputMethodListener(new java.awt.event.InputMethodListener() {

public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {

public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {

textNamaInputMethodTextChanged(evt);

});

textNama.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

textNamaActionPerformed(evt);

});

textNama.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyPressed(java.awt.event.KeyEvent evt) {

textNamaKeyPressed(evt);

});

textNIM.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

textNIMMouseClicked(evt);

});

textNIM.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {

textNIMActionPerformed(evt);

});

textAbsen.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

textAbsenMouseClicked(evt);

});

textAbsen.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

textAbsenActionPerformed(evt);

});

jLabel4.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N

jLabel4.setText("Nilai Mahasiswa");

jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

jLabel5.setText("Tugas");

jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

jLabel6.setText("UTS");
jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

jLabel7.setText("UAS");

textTugas.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

textTugasMouseClicked(evt);

});

textTugas.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

textTugasActionPerformed(evt);

});

textUTS.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

textUTSMouseClicked(evt);

});

textUTS.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

textUTSActionPerformed(evt);

});
textUAS.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

textUASMouseClicked(evt);

});

textUAS.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

textUASActionPerformed(evt);

});

tombolHitung.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N

tombolHitung.setText("HITUNG");

tombolHitung.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

tombolHitungActionPerformed(evt);

});

jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

jLabel8.setText("NILAI");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(131, 131, 131)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(textNama, javax.swing.GroupLayout.DEFAULT_SIZE, 130,


Short.MAX_VALUE)

.addComponent(textNIM)

.addComponent(tombolHitung))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(layout.createSequentialGroup()

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G, false)

.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 58,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 58,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 58,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILIN
G, false)

.addComponent(textUTS, javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(textTugas)

.addComponent(textUAS, javax.swing.GroupLayout.PREFERRED_SIZE, 33,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(textAbsen, javax.swing.GroupLayout.PREFERRED_SIZE, 33,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 53,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(31, 31, 31))))

.addGroup(layout.createSequentialGroup()

.addGap(149, 149, 149)

.addComponent(jLabel4)))

.addContainerGap(126, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(63, 63, 63)


.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(35, 35, 35)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel1)

.addComponent(textNama, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(jLabel2)

.addComponent(textNIM, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(44, 44, 44)

.addComponent(tombolHitung))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel8)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(textAbsen, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel5)
.addComponent(textTugas, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel6)

.addComponent(textUTS, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel7)

.addComponent(textUAS, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))

.addContainerGap(169, Short.MAX_VALUE))

);

pack();

}// </editor-fold>//GEN-END:initComponents

private void tombolHitungActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_tombolHitungActionPerformed

String nama, nim;

nama=textNama.getText();

nim=textNIM.getText();

if (textNama.getText().equals ("")){

nama = "Miharja";

}
if("".equals(textNIM.getText())){

nim= "171351122";

int absen,tugas,uas,uts,nilaiakhir;

absen=Integer.parseInt(textAbsen.getText());

tugas=Integer.parseInt(textTugas.getText());

uts=Integer.parseInt(textUTS.getText());

uas=Integer.parseInt(textUAS.getText());

String predikat = "";

nilaiakhir =(absen*10/100)+(tugas*20/100)+(uts*30/100)+(uas*40/100);

if( nilaiakhir >= 75 && nilaiakhir <=100){

predikat = "A";

} else if(nilaiakhir >=65){

predikat = "B";

} else if(nilaiakhir >=55){

predikat = "C";

} else if(nilaiakhir < 55 && nilaiakhir>=0){

predikat = "D";

} else {

JOptionPane.showMessageDialog(null,"\nNama : "+nama+"\nNim : "+nim+"\nNilai :


"+nilaiakhir+"\nPredikat : "+predikat);
}//GEN-LAST:event_tombolHitungActionPerformed

private void textNamaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-


FIRST:event_textNamaMouseClicked

}//GEN-LAST:event_textNamaMouseClicked

private void textNIMMouseClicked(java.awt.event.MouseEvent evt) {//GEN-


FIRST:event_textNIMMouseClicked

}//GEN-LAST:event_textNIMMouseClicked

private void textAbsenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-


FIRST:event_textAbsenMouseClicked

}//GEN-LAST:event_textAbsenMouseClicked

private void textTugasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-


FIRST:event_textTugasMouseClicked

}//GEN-LAST:event_textTugasMouseClicked

private void textUTSMouseClicked(java.awt.event.MouseEvent evt) {//GEN-


FIRST:event_textUTSMouseClicked

}//GEN-LAST:event_textUTSMouseClicked
private void textUASMouseClicked(java.awt.event.MouseEvent evt) {//GEN-
FIRST:event_textUASMouseClicked

}//GEN-LAST:event_textUASMouseClicked

private void textNIMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_textNIMActionPerformed

}//GEN-LAST:event_textNIMActionPerformed

private void textNamaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_textNamaActionPerformed

}//GEN-LAST:event_textNamaActionPerformed

private void textAbsenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_textAbsenActionPerformed

}//GEN-LAST:event_textAbsenActionPerformed

private void textUTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_textUTSActionPerformed

}//GEN-LAST:event_textUTSActionPerformed

private void textNamaAncestorMoved(javax.swing.event.AncestorEvent evt) {//GEN-


FIRST:event_textNamaAncestorMoved
}//GEN-LAST:event_textNamaAncestorMoved

private void jTextPane1(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jTextPane1

}//GEN-LAST:event_jTextPane1

private void textNamaInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-


FIRST:event_textNamaInputMethodTextChanged

}//GEN-LAST:event_textNamaInputMethodTextChanged

private void textNamaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-


FIRST:event_textNamaKeyPressed

}//GEN-LAST:event_textNamaKeyPressed

private void textNamaComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-


FIRST:event_textNamaComponentAdded

}//GEN-LAST:event_textNamaComponentAdded

private void textTugasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_textTugasActionPerformed

}//GEN-LAST:event_textTugasActionPerformed

private void textUASActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_textUASActionPerformed
}//GEN-LAST:event_textUASActionPerformed

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(() -> {

new NilaiMahasiswa().setVisible(true);

});

// Variables declaration - do not modify//GEN-BEGIN:variables

private javax.swing.JFrame jFrame1;

private javax.swing.JFrame jFrame2;

private javax.swing.JFrame jFrame3;

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.JLabel jLabel8;

private javax.swing.JTextField textAbsen;

private javax.swing.JTextField textNIM;

private javax.swing.JTextField textNama;


private javax.swing.JTextField textTugas;

private javax.swing.JTextField textUAS;

private javax.swing.JTextField textUTS;

private javax.swing.JButton tombolHitung;

// End of variables declaration//GEN-END:variables

You might also like