Press "Enter" to skip to content

jTable value show in jTextField.

Source code for mouse event page.

if(evt.getKeyCode() == KeyEvent.VK_DOWN || evt.getKeyCode() == KeyEvent.VK_UP){
try{
int row = jTable1.getSelectedRow();
String id = (jTable1.getModel().getValueAt(row, 0)).toString();
String sql = "select * from user where id = '"+id+"' ";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();

while(rs.next()){
jTextField_id.setText(rs.getString("id"));
jTextField_User.setText(rs.getString("f_name"));
jTextField_lastName.setText(rs.getString("l_name"));
jTextField_Email.setText(rs.getString("email"));
jTextField_Age.setText(rs.getString("age"));
}
}catch(SQLException e){

}
}

To get help you can see the video.

Interface of after run the page.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *