File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confuse ouput when clicking a header

 
jhon max
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.!
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic