aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes AbstractTableModel - how to highlight a particular row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "AbstractTableModel - how to highlight a particular row" Watch "AbstractTableModel - how to highlight a particular row" New topic
Author

AbstractTableModel - how to highlight a particular row

ram shyam
Ranch Hand

Joined: May 04, 2007
Posts: 77
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

Joined: Jul 26, 2007
Posts: 10451
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
jQuery in Action, 2nd edition
 
subject: AbstractTableModel - how to highlight a particular row