This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Column Click  RSS feed

 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have rendered a Jtable with ComboBoxes as shown in figure.The first column is a header column.

http://www.upload-images.net/imagen/f59f56f659.jpg

When the user selects the first column(ie: with 0 index & no Comboboxes ),I want to know that.
How will I know that the user has clicked on the first column

Thanks
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add a ListSelectionListener to the columnModels selectionModel
table.getColumnModel().getSelectionModel().addListSelectionListener()
and listen for changes in the selection. You can use
table.setColumnSelectionAllowed() to help isolate the selection.
Or you can add a MouseListener/MouseAdapter to the table and in mousePressed look for the
column index zero with
table.columnAtPoint(e.getPoint()). The tricky part is that if you allow the user to
drag the columns around this will give the view column index. You can get the correct column
model index from the TabelColumnModel.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!