• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AbstractTableModel - how to highlight a particular row

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic