I right clicked the JTable and inserted some code into “post listeners code” in an awful kludge.
I don’t see an option to add
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
to “events” in the “design” view for the JTable. I’m sure there’s a way to add a valueChanged(ListSelectionEvent evt) from design view, but how?
maybe it’s a bug?
Row selection change events are produced by ListSelectionModel of
JTable, not by JTable itself – so the event cannot be presented in
Component Inspector (as event of JTable). Handling this event must be
done manually, e.g. like:
jTable1.getSelectionModel().addListSelectionListener(
new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
customRowSelectionEventHandler(evt);
}
}
);
Although maybe there’s a way to get the ListSelectionModel for a JTable outside of the “blue”, “managed,” code?
You can create your own
ListSelectionListenerin the editable part of the source. You can add an instance of the listener to the selection model of the class variablejTable1in your table’sPost-init Codeproperty:The listener itself might look like this: