Link to home
Start Free TrialLog in
Avatar of ElishaMoshe
ElishaMoshe

asked on

"Disabled" input when used as a table's header component

I want to change my JTable and add above each column header label a TextField / Combo that will be used for filtering.

I started doing so by implementing a TableCellRenderer and in the
getTableCellRendererComponent I am returning a panel with two rows, one for the Input and one for the Label.

It looks good but I could not focus on that input (not with the mouse and not with the keyboard) it's like the input is disabled.
I thought of adding a MouseListener to the input and activate event my selt but they did not work.

How can I do this?
Avatar of ksivananth
ksivananth
Flag of United States of America image

I don't think table header is editable and so you can't set a cell editor for that. You may try below,

1. When you want to edit the text field on the table header, just show a editable text field just on top of the header field( use windo as container? ).
2. When the user type text and press enter, get the text from the editable TF and hide it and then set the text to the header text fields.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great work!