PDA

View Full Version : Cell in JTable


ld_pvl
06-08-2009, 01:07 AM
Hi,

I have a quick question about JTable. Are there any events related to a cell in a JTable, for example when a cell is edited or clicked at etc...

I want to implement some code in the case when a cell in my JTable is edited.

Thank you,

Fou-Lu
06-08-2009, 07:24 AM
Yep.
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

Check that link out for some ideas. JTable implements a CellEditListener, and also implements EventListener. With these, you can use the CellEditListener returns (there should be a getCell or getCellEditor or something like that), to use the CellEditListener, and use the EventListener to add mouse events.
I don't use a lot of gui for pretty much anything I do (CLI kinda guy), but I have used this in the past and did incorporate both.


I lied, the getCellEditor returns a TableCellEditor. Thats ok, it implements DefaultCellEditor. This is going to take a lot of playing with, so I'd definitely suggest reading that link over (I know its long).
Hope that helps!