I have created two buttons, previous and next this below is an event inside my button when jButton13 is clicked
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
// searchResults();
// System.out.println(name1);
//displayClientData();
//creating variable that will get colom values
String initials;
String nameDisp;
String surname;
String email;
String company;
String telephone;
String fax;
String physical_add;
String street_name;
String surburb;
String city;
String code;
String postal_add;
String post_str;
String post_surb;
String post_city;
String post_code;
String position;
int client_id;
name1=jTextField45.getText();
if(this.jTextField45.getText() != "")
{
jTextField45.setText(""); //Clear the textField after submiting.
//System.out.println(name1);
//jTextField46.setEditable(false);
//email1 = jTextField47.getText();
//position1 =jTextField49.getText();
String sql2 = "SELECT t1.client_id,t1.company_id,t1.initials,t1.name,t1.surname,t1.email,t1.position,t2.company_id,t2.comp any_name,t2.phone,t2.fax,t2.physical_add," +
" t2.street_name,t2.surburb,t2.code,t2.city,t2.postal_add,t2.post_str,t2.post_surb,post_city,postal_co de " +
"FROM client AS t1, company AS t2 where t1.company_id = t2.company_id AND t1.name LIKE '"+name1+"' ";
try
{
this.resultSet = this.connection.executeQuery(sql2);
while(this.resultSet.next())
{
//get the values from the database coloms values assing them to the String variable
//jTextField45.setText(" ");
client_id = this.resultSet.getInt("client_id");
jButton15.setEnabled(true);
//jButton14.setEnabled()
//System.out.println(client_id);
initials = this.resultSet.getString("initials");
nameDisp = this.resultSet.getString("name");
surname = this.resultSet.getString("surname");
email = this.resultSet.getString("email");
position= this.resultSet.getString("position");
company = this.resultSet.getString("company_name");
telephone = this.resultSet.getString("phone");
fax = this.resultSet.getString("fax");
physical_add = this.resultSet.getString("physical_add");
street_name = this.resultSet.getString("street_name");
surburb = this.resultSet.getString("surburb");
code = this.resultSet.getString("code");
city = this.resultSet.getString("city");
postal_add = this.resultSet.getString("postal_add");
post_str = this.resultSet.getString("post_str");
post_surb = this.resultSet.getString("post_surb");
post_city = this.resultSet.getString("post_city");
post_code = this.resultSet.getString("postal_code");
//displaying the results on the textField
jTextField27.setText(initials);
jTextField28.setText(nameDisp);
jTextField29.setText(surname);
jTextField33.setText(email);
jTextField31.setText(company);
jTextField32.setText(telephone);
jTextField34.setText(fax);
jTextField35.setText(physical_add);
jTextField36.setText(street_name);
jTextField37.setText(surburb);
jTextField38.setText(city);
jTextField39.setText(code);
jTextField40.setText(postal_add);
jTextField41.setText(post_str);
jTextField42.setText(post_surb);
jTextField43.setText(post_city);
jTextField44.setText(post_code);
jTextField11.setText(position);
//System.out.println(nameDisp);
}
}
catch( SQLException e )
{
e.printStackTrace( System.err );
//this.connection.close();
}
} //End of IF statement for name search value
//surname1=jTextField46.getSet(" ");
if (this.jTextField46.getText() != "")
{
surname1=jTextField46.getText();
System.out.println(surname1);
String sql2 = "SELECT t1.client_id,t1.company_id,t1.initials,t1.name,t1.surname,t1.email,t1.position,t2.company_id,t2.comp any_name,t2.phone,t2.fax,t2.physical_add," +
" t2.street_name,t2.surburb,t2.code,t2.city,t2.postal_add,t2.post_str,t2.post_surb,post_city,postal_co de " +
"FROM client AS t1, company AS t2 where t1.company_id = t2.company_id AND t1.surname LIKE '"+surname1+"' ";
try
{
this.resultSet = this.connection.executeQuery(sql2);
while(this.resultSet.next())
{
//get the values from the database coloms values assing them to the String variable
client_id = this.resultSet.getInt("client_id");
//System.out.println(client_id);
initials = this.resultSet.getString("initials");
nameDisp = this.resultSet.getString("name");
surname = this.resultSet.getString("surname");
email = this.resultSet.getString("email");
position= this.resultSet.getString("position");
company = this.resultSet.getString("company_name");
telephone = this.resultSet.getString("phone");
fax = this.resultSet.getString("fax");
physical_add = this.resultSet.getString("physical_add");
street_name = this.resultSet.getString("street_name");
surburb = this.resultSet.getString("surburb");
code = this.resultSet.getString("code");
city = this.resultSet.getString("city");
postal_add = this.resultSet.getString("postal_add");
post_str = this.resultSet.getString("post_str");
post_surb = this.resultSet.getString("post_surb");
post_city = this.resultSet.getString("post_city");
post_code = this.resultSet.getString("postal_code");
//displaying the results on the textField
jTextField27.setText(initials);
jTextField28.setText(nameDisp);
jTextField29.setText(surname);
jTextField33.setText(email);
jTextField31.setText(company);
jTextField32.setText(telephone);
jTextField34.setText(fax);
jTextField35.setText(physical_add);
jTextField36.setText(street_name);
jTextField37.setText(surburb);
jTextField38.setText(city);
jTextField39.setText(code);
jTextField40.setText(postal_add);
jTextField41.setText(post_str);
jTextField42.setText(post_surb);
jTextField43.setText(post_city);
jTextField44.setText(post_code);
jTextField11.setText(position);
//System.out.println(nameDisp);
}
} //end of try
catch( SQLException e )
{
e.printStackTrace( System.err );
//this.connection.close();
}
}
} //end of method