I have a JTable (master) to which I added a ListSelectionListener to catch when a row is selected and populate another JTable (detail) according the selected row.
Now some requirements have changed and if come conditions are met, when the user clicks into another row, I should show a JOptionPane with YES/NO options, and only if YES is clicked then the new row can be selected.
How can I achieve this? Shall I use always ListSelectionListener? I don't think so as it is raised only after the selection is done.
JTable: waiting for row to be selected according user input
171 views Asked by SagittariusA At
2
There are 2 answers
0
On
when the user clicks into another row,
What about when the user used the up/down arrow keys to move to another row?
The default behaviour in both cases is to select the row automatically.
You might be able to override the changeSelection(...) method of the JTable. I believe this is the method that is invoked by the mouse or keyboard logic to change row selection.
So you would add your logic to display the option pane and then if "Yes" is selected you would invoke super.changeSelection(...).
However, I would find it frustrating to try and use the keyboard to scroll down the table if this option pane keeps popping up. Remember to design a user interface that support both mouse and keyboard effectively.
yes, for sure