wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confuse ouput when clicking a header
 
Similar Threads
how to delete a row header
JTable
JTable listening for selected rows and columns by a keypress event
JTable
JTable with RadioButton Headers