Here is how to set up a double-click event that opens a new form:
1) First set up Mouse Listener on your JTable:
myJTable.addMouseListener(new MouseAdapter() {This will give you the row and column that was double clicked.
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
JTable target = (JTable)e.getSource();
int row = target.getSelectedRow();
int column = target.getSelectedColumn();
// do some action
}
}
});
2) You can then use this to get the value of that row's ID and open a new form and populate it with this record's data. Here is how you would open a new form
JFrame newFrame = new JFrame();The below link was useful in working out how to do this and has many other helpful items:
newFrame.setTitle("Detail Screen");
newFrame.setVisible(true);
Detect Double Click