/**
*
@(#)datamahasiswa.java
*
*
* @author
* @version 1.00
2012/4/15
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class datamahasiswa extends JFrame implements
ActionListener
{
private JTextField jTFinput1,jTFinput2,jTFinput3,jTFinput4,jTFinput5,jTFinput6,jTFinput7,jTFhasil;
private JButton btnhitungnilai, btnkeluar;
public static void main(String[] args)
{
datamahasiswa frame = new datamahasiswa();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public datamahasiswa()
{
setTitle("FORM
DATA KELOLAH NILAI NILAI MAHASISWA ");
setBackground(Color.yellow);
setForeground(Color.black);
JPanel
p1= new JPanel();
p1.setLayout(
new GridLayout(5,1));
p1.add(new
JLabel("NIM :"));
p1.add(jTFinput1=
new JTextField(3));
p1.add(new
JLabel("Nama :"));
p1.add(jTFinput1=
new JTextField(3));
p1.add(new
JLabel("Kelas :"));
p1.add(jTFinput2=
new JTextField(3));
p1.add(new
JLabel("Absensi 10% :"));
p1.add(jTFinput3=
new JTextField(3));
p1.add(new
JLabel("Nilai Tugas 20%
:"));
p1.add(jTFinput4=
new JTextField(3));
p1.add(new
JLabel("Nilai UTS 30% :"));
p1.add(jTFinput5=
new JTextField(3));
p1.add(new
JLabel("Nilai UAS 40% :"));
p1.add(jTFinput6=
new JTextField(3));
p1.add(new
JLabel("Hasil Nilai :"));
p1.add(jTFhasil=
new JTextField(5));
jTFhasil.setEditable(false);
Dimension
dim= new Dimension(900,150);
p1.setPreferredSize(dim);
JPanel
p2= new JPanel();
p2.setLayout(new
FlowLayout());
p2.add(btnhitungnilai
= new JButton("Hitung"));
p2.add(btnkeluar=new
JButton("Selesai"));
getContentPane().setLayout(new
BorderLayout());
getContentPane().add(p1,BorderLayout.CENTER);
getContentPane().add(p2,BorderLayout.SOUTH);
btnhitungnilai.addActionListener(this);
btnkeluar.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if
(e.getSource()==btnhitungnilai){
int
bilangan3=(Integer.parseInt(jTFinput3.getText().trim()));
int
bilangan4=(Integer.parseInt(jTFinput4.getText().trim()));
int
bilangan5=(Integer.parseInt(jTFinput5.getText().trim()));
int
bilangan6=(Integer.parseInt(jTFinput6.getText().trim()));
int
hasil=(bilangan3*10/100)+(bilangan4*20/100)+(bilangan5*30/100)+(bilangan6*40/100);
jTFhasil.setText(String.valueOf(hasil));
}
else
if (e.getSource()==btnkeluar)
{System.exit(0);}
}
}
2. Tampilan
Tidak ada komentar:
Posting Komentar