Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-2007, 06:59 PM
Member
 
Join Date: Jul 2007
Posts: 44
susan is on a distinguished road
Java Next Button for displaying next row
Hi all, My problem from last time is still with me unfortunately,
  • I have a text field which you enter a name to search.
    in my button i calling this method called displayCurrentRow()
Code:
private void displayCurrentRow() { //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 company_id; int client_id; name1=jTextField45.getText(); if(!"".equals(this.jTextField45.getText())) { jTextField45.setText(""); //Clear the textField after submiting. String sql2 = "SELECT t1.client_id,t1.company_id, t1.initials,t1.name,t1.surname,t1.email, t1.position,t2.company_id,t2.company_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,t2.post_city, t2.postal_code " + "FROM client AS t1, company AS t2 WHERE t1.company_id = t2.company_id AND t1.name LIKE '%"+name1+"%'"; int count =0; //extract one row 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 if(count == currentRow) { jButton15.setEnabled(true); //(Next Button) jButton14.setEnabled(true);//(Prv Button) //System.out.println(client_id); initials = this.resultSet.getString(3); nameDisp = this.resultSet.getString(4); surname = this.resultSet.getString(5); email = this.resultSet.getString(6); position= this.resultSet.getString(7); company = this.resultSet.getString(9); telephone = this.resultSet.getString(10); fax = this.resultSet.getString(11); //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); jTextField11.setText(position); } count++; } resultSet.close(); connection.close(); } catch( SQLException e ) { e.printStackTrace( System.err ); } } //End of IF statement for name search value }

  • Then i call this methed displayCurrentRow() in my button "submit" which displays the data on the form,it works the data gets displayed.
  • Then i have a method called nextPressed()

Code:
private void nextPressed() { currentRow++; displayCurrentRow(); //displayCurrentRow(); }
This method is called in my button next, so when the button is cliked currentRow should increment then dispaly the next record.

i have the previous methed as well,but i am not gettting the results i need,my next button does nothing

Can someone spot what i am doing wrong.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 05:16 AM
Member
 
Join Date: Jul 2007
Posts: 40
cachi is on a distinguished road
When you pull the data from the database, what do you do with that data?

For example, one approach would be to (1) get the data from the database, (2) create an array of elements that of type "Employee" or whatever the database table stores data for, (3) create new instances of type "Employee" and append them to the array you have created.

Once you have done that, then you don't need to make calls to the database..as you already have an array populated with data. then your focus should be placed on making the buttons (i.e. New, Previous...etc) pull data from the array instead of making SQL calls.

I am sure that there are other ways to do this, but I personally find this approach to be easier to program. Of course, you can use "Collections", which I personally prefer to arrays...as you can add elements to a given collection as and when needed.

Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
java applet button problem .. :( plz help i4gotmyid New To Java 0 04-05-2008 10:55 AM
search button java applet awt perplexingtrax New To Java 2 03-24-2008 02:49 PM
Displaying a Java List in Html:select tag ramitmehra123 New To Java 0 02-07-2008 06:48 AM
Displaying text in a JTextField after pressing a button RLRExtra New To Java 5 01-17-2008 10:01 PM
addActionListener(java.awt.event.ActionListener) in java.awt.Button cannot be applied mathias Java Applets 1 08-06-2007 09:49 AM


All times are GMT +3. The time now is 04:13 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org