• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable How to prevent a column being selected.  RSS feed

 
Harry Wood
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable where the user is allowed to select rectagular areas. I want to prevent the rectangular selection ever going over the leftmost column. Well in fact it doesn't matter if the user drags a rectangle over this column, but I don't want a click on single cell in the leftmost column to remove the previously selected rectangle.

I am going to try to do this by storing the selection state after every change (ListSelectionListener.valueChanged), and then immediatly reverting any changes which include the leftmost column. But this really seems like a ugly workaround. Anyone know a better way of preventing selections in one particular column.

In general it seems quite difficult to take control of rectangular selections in a JTable. The ListSelectionModel is really designed for Lists after all. Maybe someone has alternative implementations, or a wrapper class which makes this easier. Wishful thinking perhaps.

Any suggestions much appreciated.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!