Vous êtes sur la page 1sur 6

/*

* PertamaFrame.java
*
* Created on October 9, 2006, 3:43 PM
*/
import javax.swing.*;

/**
*
* @author mahasiswa
*/
public class PertamaFrame extends javax.swing.JFrame {

/** Creates new form PertamaFrame */


public PertamaFrame() {
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.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtNAMA = new java.awt.TextField();
txtMID = new java.awt.TextField();
txtSEM = new java.awt.TextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();

getContentPane().setLayout(null);

setBackground(new java.awt.Color(51, 153, 0));


setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});

jLabel1.setBackground(new java.awt.Color(255, 255, 255));


jLabel1.setFont(new java.awt.Font("Lucida Console", 1, 11));
jLabel1.setText("NAMA MAHASISWA");
jLabel1.setBorder(new
javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jLabel1);
jLabel1.setBounds(20, 20, 120, 16);

jLabel2.setFont(new java.awt.Font("Lucida Console", 1, 11));


jLabel2.setText("NILAI MID");
jLabel2.setBorder(new
javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jLabel2);
jLabel2.setBounds(20, 50, 120, 16);

jLabel3.setFont(new java.awt.Font("Lucida Console", 1, 11));


jLabel3.setText("NILAI SEMESTER");
jLabel3.setBorder(new
javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
getContentPane().add(jLabel3);
jLabel3.setBounds(20, 80, 120, 16);

txtNAMA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtNAMAActionPerformed(evt);
}
});

getContentPane().add(txtNAMA);
txtNAMA.setBounds(190, 20, 120, 20);

txtMID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtMIDActionPerformed(evt);
}
});

getContentPane().add(txtMID);
txtMID.setBounds(190, 50, 120, 20);

getContentPane().add(txtSEM);
txtSEM.setBounds(190, 80, 120, 20);

jButton1.setFont(new java.awt.Font("Comic Sans MS", 3, 14));


jButton1.setText("PROSES");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

getContentPane().add(jButton1);
jButton1.setBounds(20, 150, 90, 31);

jButton2.setFont(new java.awt.Font("Comic Sans MS", 3, 14));


jButton2.setText("LAGI");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

getContentPane().add(jButton2);
jButton2.setBounds(160, 150, 90, 31);

jButton3.setFont(new java.awt.Font("Comic Sans MS", 3, 14));


jButton3.setText("EXIT");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

getContentPane().add(jButton3);
jButton3.setBounds(290, 150, 90, 31);

pack();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(1);
}

private void txtNAMAActionPerformed(java.awt.event.ActionEvent evt) {

private void txtMIDActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
txtNAMA.setText("");
txtMID .setText("");
txtSEM .setText("");

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String NAMA,KET="";
int MID,SEM;
double NA;
char NH;
NAMA= txtNAMA.getText();
MID = Integer.parseInt(txtMID.getText());
SEM = Integer.parseInt(txtSEM.getText());
NA=(MID+SEM)*0.5;
if(NA>80)
{
NH ='A';
KET ="EXELLENT";
}
else if(NA>65)
{
NH ='B';
KET ="VERY GOOD";
}
else if(NA>50)
{
NH ='C';
KET ="GOOD";
}
else if(NA>40)
{
NH ='D';
KET ="GAGAL";
}
else
{
NH ='E';
KET ="ULANG";
}
JOptionPane.showMessageDialog(null,"NAMA= "+NAMA+
"\n NILAI MID = "+MID+
"\n NILAI SEMESTER = "+SEM+
"\n NILAI ANGKA = "+NA+
"\n NILAI HURUF = "+NH+
"\n KETERANGAN = "+KET);
}

/** Exit the Application */


private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
PertamaFrame a = new PertamaFrame();
a.setLocation(100,100);
a.setSize(400,250);
a.show();
}

// Variables declaration - do not modify


private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private java.awt.TextField txtMID;
private java.awt.TextField txtNAMA;
private java.awt.TextField txtSEM;
// End of variables declaration
}

Vous aimerez peut-être aussi