First you need to add a listener to Listen for changes in the text, then send that text to your query to retrieve new data based on the passed text.
// Listen for changes in the text
textField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
warn();
}
public void removeUpdate(DocumentEvent e) {
warn();
}
public void insertUpdate(DocumentEvent e) {
warm();
}
public void warn() {
// fire the execute statement.
}
});
then you need to change your query to something like this:
String sql = "SELECT studentno, lastname, firstname, middlename FROM student WHERE firstname= '" + jtextfield.getText() + "%'";