aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes confuse ouput when clicking a header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "confuse ouput when clicking a header " Watch "confuse ouput when clicking a header " New topic
Author

confuse ouput when clicking a header

jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45


Im having some problem regarding with displaying the selected column header, Im getting -1, how am i supposed to resolve this.. thanks!
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Your current code sets the selected column index before any mouse click has been performed:


So it shouldn't be surprising that the only output here is -1. But further, when you click on a column header, afaik, you don't select a column, so even if the getSelectedColumn() call were placed inside of the mouseClicked method, it still won't work. Perhaps what might work better is to call JTableHeader's columnAtPoint method like so:



Also, I personally usually prefer to act on mousePressed and not mouseClicked.
jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45
thank you.!
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
jhon max wrote:thank you.!


You're welcome and also a caveat: I'm about 90% sure of my answer, but since I'm not a pro, keep an eye on this thread. Usually if the pros see something amiss in my rec, they'll correct it.

Good luck!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: confuse ouput when clicking a header