jump to navigation

Belajar Java Validation Sederhana December 22, 2011

Posted by kelompok24itbseamolecb5 in Pemrograman Java.
trackback

Oke kita lanjut ketahap pembelajara selanjutnya…

Disini kita membuat form input data beserta validasi inputannya

Yaitu dimana sebelum data dieksekusi di cek dulu kalau-kalau ada data yang tak terisi..

Pertama kalian bikin form seperti disamping dulu..

Langsung ke pengkodingan aja ya soalnya kalo soal bikin

Form kalian pasti bisa deh tinggal Drag-Drop aja di

Pallete NetBeans..

Soure code buat Radio Button:

public class Program2 extends javax.swing.JFrame {/** Creates new form Program2 */private ButtonGroup gabung;public Program2() {initComponents();gabung = new ButtonGroup();gabung.add(jRB_laki);

gabung.add(jRB_perempuan);

}

Soure code buat Button Simpan,Hapus,dan Keluar:

private void jB_simpanActionPerformed(java.awt.event.ActionEvent evt){String jk=””;String agama=””;if(jRB_laki.isSelected()){jk=”Laki-Laki”;}else if(jRB_perempuan.isSelected()){jk=”Perempuan”;

}

agama=jComboBox1.getSelectedItem().toString();

jTextArea2.setText(jTF_nama.getText() + “\n” + jk + “\n” +

“\n” + agama + “\n” + jTF_hobi.getText() + “\n” +

jTF_telp.getText() + “\n” + jTF_email.getText()+ “\n” +jTA_alamat.getText());

}

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

jTF_nama.setText(null);

jTF_hobi.setText(null);

jTF_telp.setText(null);

jTF_email.setText(null);

jTA_alamat.setText(null);

}

 

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

int psn1=JOptionPane.showConfirmDialog(null, “Keluar Dari Aplikasi?”);

if(psn1==JOptionPane.OK_OPTION){

System.exit(1);

}else{

}

// TODO add your handling code here:

}

Try and try if you want learning java programming…..

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: