on the project, this time using the provisions of author names the following components to facilitate understanding in making the program code.
Component Component Name Changes
JTextField No Anggota — no
JTextField Nama — nama
JTextField Alamat — alamat
JComboBox Agama — agama
JRadioButton Jkel — RPria dan RWanita
JTextField No KTP — noktp
JTextField No. Telp — notelp
JTextField Simpanan — simpanan
JButton Simpan — bsimpan
JButton Data Baru — bbaru
JButton Keluar — bkeluar
3. After you change the name of each component so it's time to process incoming Coding.
Program Code:
- Below the tab name of your project, click the source:
Under the package type you import the following command to retrieve the sql commands.
=======================================================
import java.sql;
=======================================================
- The declaration of a variable connection, resultset, statement and the other variables that are required
Public under the following class type variables;
=======================================================
//deklarasi variabel global
Connection Con;
ResultSet RsAng;
Statement StatAng;
//variabel for agama
String sagm = “1″;
//variabel for jenis kelamin
Boolean bjkel = true;
//variabel global where data ditemukan
Boolean ada = false;
- Then, under public nama_project (under the introduction of a variable) type the command database connection and table below:
//connection
try
{
String fdata = “z:\\java1\\NetBeans\\Koperasi.mdb”;
Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);
// direct connection to the database without dsn
Con= DriverManager.getConnection(”jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=” + fdata);
//shows the search process can be in the resultset update
StatAng= Con.createStatement( RsAng.TYPE_SCROLL_SENSITIVE, RsAng.CONCUR_UPDATABLE );
RsAng = StatAng.executeQuery(”Select* from Anggota”);
}
catch(Exception e)
{ System.err.println(”Conection error !” + e.getMessage()); } //getMessage to display the message
=======================================================
- After the connection is successful then the time we go to the key store. Type the following code:
================================================== ====
private void bsimpanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try
{
RsAng.updateString(”Noang”, no.getText());
RsAng.updateString(”Nama”, nama.getText());
RsAng.updateString(”Alamat”, alamat.getText());
RsAng.updateString(”Agama”, sagm);
RsAng.updateBoolean(”Jkel”, bjkel);
RsAng.updateString(”NoKTP”, noktp.getText());
RsAng.updateString(”NoTelp”, notelp.getText());
RsAng.updateDouble(”Simpanan”, Double.parseDouble(simpanan.getText()));
if(ada)
{
//mengedit data yang sudah ada
RsAng.updateRow();
javax.swing.JOptionPane.showMessageDialog(null, “Data Telah Diedit !”);
}
else
//menyisipkan record baru
RsAng.insertRow();
javax.swing.JOptionPane.showMessageDialog(null, “Data Telah Tersimpan !”);
}
catch(Exception e)
{
javax.swing.JOptionPane.showMessageDialog(null, “Data Belum Tersimpan !” + e.getMessage());
}
}
======================================================
- Code Programs for RadioButton Male:
======================================================
private void RPriaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bjkel = true;
}
======================================================
- Code Programs for Women's RadioButton:
======================================================
private void RWanitaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bjkel = false;
}
=====================================================
- To type a ComboBox in the code the program:
=====================================================
private void agamaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// Baca Source objectnya masih JcomboBox
javax.swing.JComboBox soagama = (javax.swing.JComboBox)evt.getSource();
//Membaca Item Yang Terpilih — > String
String sagama = (String)soagama.getSelectedItem();
//pengujian sagama
if (sagama.equals(”Islam”))
sagm = “1″;
else if (sagama.equals(”Kristen”))
sagm = “2″;
else if (sagama.equals(”Hindhu”))
sagm = “3″;
else if (sagama.equals(”Budha”))
sagm = “4″;
else if (sagama.equals(”Konghu Chu”))
sagm = “5″;
}
=====================================================
- Keys To New Data type program:
=====================================================
private void bbaruActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
no.setText(”");
nama.setText(”");
alamat.setText(”");
noktp.setText(”");
notelp.setText(”");
simpanan.setText(”");
}
=====================================================
- To Exit Button component type in the code the program:
=====================================================
private void bkeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//Tutup Koneksi
try
{
Con.close();
RsAng.close();
StatAng.close();
Con = null; RsAng = null; StatAng = null;
}
catch (Exception e){}
System.exit(0);
}
====================================================
Additional notes (rusted Bos)
- To fill the ComboBox religion you click on the ComboBox component on the properties and religious search model, then click the dialog box will appear as follows:

- Add the components in the form buttongroup note discount image below:

Drag to your form. But you will not see But wujudnya.hehehehehe to change the name of the components please enter your navigator to the left side of your monitor. Change the name of its components with the name "bgjkel"

- After entering ButtonGroup components and change the name then click on the component RPria and RWanita properties and then on the search button and change the group into bgjkel.

Congratulations you try a new project in NetBeans IDE 6.5
Author apologize because order is still not known to this article. Because I do not have spare time to improve the view. Thank you already want to visit.