• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

JTable How to prevent a column being selected.

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic