A brief description of the problem.
Suppose JTable and the user interact with it in some way. Table The model of this table is constantly changing. How to make sure that when a user tries to get some information from a table, referring to some constant column and the row currently selected (by its rowIndex, which he received from JTable), he will not get into the situation when the TableModel is changed, but its rowIndex received from JTable no longer matches a single value in the TableModel.
The following is an initial question that explains the problem in more detail:
Consider the following situation:
There is a JTable that shows information about users in the current run of queries on some system
When a new query enters the system, a new row is added to the table
The user can interact with the table by right-clicking on a row (a single row selection model is used in the table) and selecting an item in the menu (for example: interrupt, postpone, try again, etc.)
there is a separate class that implements the ActionListener interface (listens to the table) and processes all user interactions
When a user performs an action on a table, this class validates the currently selected row and assigns some values to the user action (basically it takes the index of the selected row and then calls tableModel.getValueAt (indexOfSelectedRow, someValuableDataColumnIndex))
, -, . , , , , , ( , , ). , , inits - .
, . :
- invokeAndWait() ( , imo )
, , TableModel. , , , , . ( , )
, .
, , - , .