Anda di halaman 1dari 5

import import import import import import

javax.swing.JOptionPane; javax.swing.*; java.awt.*; java.awt.event.*; java.io.*; java.lang.*;

class M5 extends JFrame implements ActionListener { private JButton smpn, keluar, hapus; private JTextField nama, nbi, almt, TL, fakultas, kelas, bpp, sk s, ambil; private JComboBox agama, fakultas1, kelas1; private Checkbox cb1, cb2; private CheckboxGroup cbg; private Icon gambar; private JLabel nam, nb, alm, T, gam, g, JK, agm, fk, kl, bp, ks, abl,g1,g2,g3,g4,g5; M5() { super("FORM REGISTRASI"); setSize(900,400); smpn=new JButton("Daftarkan"); keluar=new JButton("Keluar"); hapus=new JButton("Hapus"); nama=new JTextField(20); nbi=new JTextField(20); almt=new JTextField(20); bpp=new JTextField(20); sks=new JTextField(20); ambil=new JTextField(20); TL=new JTextField(20); fakultas = new JTextField(20); kelas = new JTextField(20); cbg=new CheckboxGroup(); cb1=new Checkbox("Pria",cbg,true); cb2=new Checkbox("Wanita",cbg,false); nam=new JLabel("Nama\t\t: "); nb=new JLabel("Usia\t\t: "); alm=new JLabel("Alamat\t: "); T=new JLabel("TGL Lahir\t: "); JK=new JLabel("Kelamin\t: "); abl=new JLabel("Jumlah SKS yang diambil\t:");

agm=new JLabel("Agama\t: "); Object[] ag={"KRISTEN","BUDHA","HINDU","ISLAM"," KATOLIK"}; agama=new JComboBox(ag); fk=new JLabel("Fakultas\t:"); Object[] fkt={"Teknik","Kelautan","Sastra","Ekon omi"}; fakultas1=new JComboBox(fkt); kl=new JLabel("Kelas Perkuliahan\t:"); Object[] kls={"Kelas Pagi","Kelas Malam"}; kelas1=new JComboBox(kls); bp=new JLabel("Pembayaran BPP Pokok ( Rp. 2.250. 000 )\t: "); ks=new JLabel("Pembayaran SKS ( @ : Rp. 90.000)\ t: "); gambar=new ImageIcon("unsada.jpg"); gam=new JLabel(gambar); g=new JLabel("UNIVERSITAS DHARMA PERSADA"); g1=new JLabel("KELOMPOK :"); g2=new JLabel("1.ARDIANSYAH ( 2010230021 )"); g3=new JLabel("2.PRATIKA ARONA MAWARI ( 20102300 99 )"); g4=new JLabel("3.FRISCA PANJAITAN ()"); g5=new JLabel("4. ()"); JPanel p=new JPanel(); p.add(cb1);p.add(cb2); JPanel p1=new JPanel(); p1.setLayout(new GridLayout(14,10,18,18)); p1.add(nam);p1.add(nama); p1.add(nb);p1.add(nbi); p1.add(alm);p1.add(almt); p1.add(T);p1.add(TL); p1.add(agm);p1.add(agama); p1.add(fk);p1.add(fakultas1); p1.add(kl);p1.add(kelas1); p1.add(JK);p1.add(p); p1.add(bp);p1.add(bpp); p1.add(ks);p1.add(sks); p1.add(abl);p1.add(ambil); JPanel p2=new JPanel(); p2.add(smpn);p2.add(keluar);p2.add(hapus); JPanel p3=new JPanel(); p3.setLayout(new GridLayout(1,1,10,10)); p3.add(p1); JPanel p4=new JPanel(); p4.add(gam); JPanel p5=new JPanel(); p5.add(g); p5.add(g1); p5.add(g2); p5.add(g3); p5.add(g4); p5.add(g5); p5.setLayout(new GridLayout(8,1,10,10));

JPanel p6=new JPanel(); p6.setLayout(new GridLayout(2,1,10,10)); p6.add(p4);p6.add(p5); JPanel p7=new JPanel(); p7.add(p3); JPanel p8=new JPanel(); p8.add(p6); Container c=getContentPane(); c.add("West",p7); c.add("East",p8); c.add("South",p2); smpn.addActionListener(this); keluar.addActionListener(this); hapus.addActionListener(this); show(); } public void actionPerformed(ActionEvent a) { int kurangbpp, sksambil, skskurang, totalkurang; if(a.getSource()==smpn){ boolean kondisi=true; try{File file=new File("d://Modu l 5.txt"); PrintWriter fout=new PrintWriter (new FileWriter(file.getPath(),kondisi));

fout.println("Nama :"+nama.getTe xt()+" \n"); fout.println("Usia :"+nbi.getTex t()+" Tahun \n"); fout.println("Alamat :"+almt.get Text()+" \n"); fout.println("Tanggal Lahir :"+T L.getText()+" \n "); fout.println("Agama :"+agama.get SelectedItem().toString()+" \n "); fout.println("Jenis Kelamin :"+c bg.getSelectedCheckbox().getLabel()+" \n"); fout.println("Fakultas :"+fakult as1.getSelectedItem().toString()+" \n "); fout.println("Kelas Perkuliahan :"+kelas1.getSelectedItem().toString()+" \n "); fout.println("Pembayaran BPP POk ok :"+bpp.getText()+" \n"); fout.println("Jumlah SKS yang di ambil :"+ambil.getText()+" \n"); fout.println("Pembayaran SKS :"+ sks.getText()+" \n"); int bpp2 =Integer.parseInt(bpp.g etText()); int sks2 =Integer.parseInt(sks.g etText()); int ambil2 =Integer.parseInt(amb il.getText());

kurangbpp = 2250000-bpp2; sksambil = ambil2*90000; skskurang = sksambil - sks2; totalkurang = kurangbpp+skskuran g; fout.println("Kekurangan Pembaya ran :"+totalkurang+" \n"); fout.println("\n"); fout.println("\n"); fout.println("------------------------------------------------------------"); fout.close(); JOptionPane.showMessageDialog(nu ll,"DATA BERHASIL DISIMPAN \n" + "Nama :"+nama.getText()+ "\nUsia :"+nbi.getText()+ "\nAlamat :"+almt.getText()+ "\nTanggal Lahir :"+TL.getText() + "\nAgama :"+agama.getSelectedIte m().toString()+ "\nJenis Kelamin :"+cbg.getSelec tedCheckbox().getLabel()+ "\nFakultas :"+fakultas1.getSele ctedItem().toString()+ "\nKelas Perkuliahan :"+kelas1.g etSelectedItem().toString()+ "\nPembayaran BPP Pokok :"+bpp.g etText()+ "\nPembayarn SKS :"+sks.getText( )+ "\nJumlah SKS yang diambil :"+am bil.getText()+ "\nKekurangan Pembayaran Anda =" +totalkurang);

nama.setText(""); nbi.setText(""); almt.setText(""); TL.setText(""); agama.setSelectedIndex(0); agama.setSelectedIndex(0); fakultas1.setSelectedIndex(0); kelas1.setSelectedIndex(0); bpp.setText(""); sks.setText(""); ambil.setText(""); }catch(IOException io){

io.printStackTra ce(); } } else if(a.getSource()==keluar) { JOptionPane.showMessageDialog(null,"TERI MA KASIH"); System.exit(0); } else if(a.getSource()==hapus){ nama.setText(""); nbi.setText(""); almt.setText(""); TL.setText(""); agama.setSelectedIndex(0); fakultas1.setSelectedIndex(0); kelas1.setSelectedIndex(0); bpp.setText(""); sks.setText(""); ambil.setText(""); JOptionPane.showMessageDialog(nu ll,"DATA BERHASIL DIHAPUS"); //cb1.setSelected(true); } } public static void main(String[] args) { M5 oby=new M5(); } }