File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Column Click Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Column Click" Watch "Column Click" New topic
Author

Column Click

Arun Sanker
Ranch Hand

Joined: Mar 21, 2007
Posts: 44
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

Joined: Jan 14, 2004
Posts: 1535
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Column Click
 
Similar Threads
How to change mouse cursor during drag and drop
Simple Swing
My thoughts about the search dialog implementation
bytearray image decoding
Using Comboboxes with JTable where first row displaying comboxes.