Alex Kravets wrote: > Hello, > > I want to add code to my applet so that when a user clicks inside one > of the JTable's cells it gets highlighted. I figured if I can use > CellEditor to make cells JTextField, I can use selectAll() to select > the text. Below is the code that I have so far, if anyone can > contribute, I would appreciate it very much. > > thanks, > Alex > > _______________________________________________ > Advanced-swing mailing list > [EMAIL PROTECTED] > http://eos.dk/mailman/listinfo/advanced-swing > > I think I tried to accomplish something similar recently, but I was only concerned about JTextField cells. I subclassed DefaultCellEditor and overrode getTableCellEditorComponent, which calls requestFocus() on the editorComponent before returning it. It is also a FocusListener on the returned component, and selects the text when it receives focus. I'm sure there's a zillion perhaps better ways to do it, but this worked for me.
I would like to expand the question: I want the user to be able to enter text in the focused/selected textfield simply by tabbing to that cell, but I am disappointed to see that getTableCellEditorComponent is not called until a mouseclick in the cell happens. How can I cause editing to commence immediately when the user navigates to a cell with the keyboard? Andy Wiese --code carpenter amongst software engineers-- _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing
