• Post Reply Bookmark Topic Watch Topic
  • New Topic

Disabled JTable header still sorts

 
Vijay Vishwanath
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks Craig, i have done this and it is working
but the column drag still works...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!