• 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

Disabled JTable header still sorts

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I'm using a JTable in my application. I have added a row sorter
for the JTable. This JTable is shown in "Edit" mode and "View" mode.
In the "View" mode, I have disable the JTable and also its JTableHeader.
The problem is, even after the header is disabled, it still accepts
mouse input and sorts the table which is exactly the opposite
of what i want the JTable to do.
I have tried googling and found somewhere that this is
a bug in java swing. If yes, is there a workaround for this?
If not, how do i disable the table header so that it doesnt
accept mouse input? Please help.

Thanks in advance.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your mouse code block that triggers the sorting you can check if the JTableHeader is enabled/disabled and use this to determine whether or not to sort the table.

You are using the state of the JTableHeader as a flag in your mouse code.
 
Vijay Vishwanath
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Craig, i have done this and it is working
but the column drag still works...
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic