Simplest way of creating java next/previous buttons

Posted by Holly on Stack Overflow See other posts from Stack Overflow or by Holly
Published on 2010-05-14T21:15:23Z Indexed on 2010/05/14 22:04 UTC
Read the original article Hit count: 237

Filed under:
|
|

I know that when creating buttons, like next and previous, that the code can be somewhat long to get those buttons to function.

My professor gave us this example to create the next button:

    private void jbtnNext_Click() {
        JOptionPane.showMessageDialog(null, "Next" ,"Button Pressed", 
            JOptionPane.INFORMATION_MESSAGE);        

    try {
        if (rset.next()) {
            fillTextFields(false);
        }else{
            //Display result in a dialog box
            JOptionPane.showMessageDialog(null, "Not found");
    }
}
    catch (SQLException ex) {
        ex.printStackTrace();
    }
}

Though, I do not really understand how that short and simple if statement is what makes the next button function. I see that the fillTextFields(false) uses a boolean value and that you need to initialize that boolean value in the beginning of the code I believe. I had put private fillTextFields boolean = false; but this does not seem to be right...

I'm just hoping someone could explain it better. Thanks :)

© Stack Overflow or respective owner

Related posts about java

Related posts about buttons