Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AbstractTableModel - how to highlight a particular row

 
ram shyam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using AbstractTableModel to display a table of data in the GUI. In this table, on double-clicking a particular row, a pop-up window is displayed and on pressing "ok", the pop-up is closed. After this, the highlighted row goes to the first row of the table. I would like to know how to highlight the same row which has been clicked, rather than highlighting the first row always (after the pop-up is closed, ie, after the call to setValueAt() of this table model). For eg., if there are more no. of rows in the table, after clicking a particular row in the bottom, opening and closing the pop-up window, the highlight again goes back to the first row after which I have to scroll down back to the previously clicked row.
Is it feasible to have the highlight on the same row?

Please clarify.

Thanks in advance!!
 
Maneesh Godbole
Saloon Keeper
Posts: 11196
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ram shyam:
Hi all,
...Is it feasible to have the highlight on the same row?


The AbstractTableModel or rather any table model is not aware of selections. It is handled by the ListSelectionModel.
You will need to remember the current selection and reset it back after editing.
Take a look at JTable#getSelectionModel and ListSelectionModel#setSelectionInterval.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic