Results 1 to 2 of 2
  1. #1
    susan is offline Member
    Join Date
    Jul 2007
    Rep Power

    Default 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()

    Java 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;
    jTextField45.setText(""); //Clear the textField after submiting.
    String sql2 = "SELECT t1.client_id,t1.company_id,
    t1.position,t2.company_id,t2.company_name,,t2.fax,t2.physical_add," +
    " t2.street_name,t2.surburb,t2.code,,
    t2.postal_code " +
    "FROM client AS t1, company AS t2
    WHERE t1.company_id = t2.company_id AND
    LIKE '%"+name1+"%'";
    int count =0; //extract one row
    this.resultSet = this.connection.executeQuery(sql2);
    //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)
    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
    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()

    Java Code:
    private void nextPressed()
    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.

  2. #2
    cachi is offline Member
    Join Date
    Jul 2007
    Rep Power


    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 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 you can add elements to a given collection as and when needed.


Similar Threads

  1. Replies: 3
    Last Post: 03-26-2009, 11:31 PM
  2. java applet button problem .. :( plz help
    By i4gotmyid in forum New To Java
    Replies: 0
    Last Post: 04-05-2008, 09:55 AM
  3. search button java applet awt
    By perplexingtrax in forum New To Java
    Replies: 2
    Last Post: 03-24-2008, 02:49 PM
  4. Displaying a Java List in Html:select tag
    By ramitmehra123 in forum New To Java
    Replies: 0
    Last Post: 02-07-2008, 06:48 AM
  5. Replies: 5
    Last Post: 01-17-2008, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts