views:

33

answers:

1

I have a table ( in which I make a table cell editor consisting of a text field and a button. Clicking the button brings up a pop up menu with a date picker. The idea is that the text field should be updated whenever a date is selected in the date picker.

Problem is, when interacting with the date picker, the focus of the cell editor is lost, and as a result, the table is removed from the editor as a cell editor listener (JTable.editingStopped()).

Since the listener is removed, calling fireProperyChange() in the cell editor when a new date is set have no effect and no updates are propagated to the table / text field.

Do you have any ideas on how I can achieve the behavior I want?

Thank you.

Here's the call stack after setting a date in the picker:

PropertySheetTable(JTable).editingStopped(ChangeEvent) line: 4713
CellEditorAdapter(AbstractCellEditor).fireEditingStopped() line: 125
CellEditorAdapter.stopCellEditing() line: 152
JTable$CellEditorRemover.propertyChange(PropertyChangeEvent) line: 5954 PropertyChangeSupport.firePropertyChange(PropertyChangeEvent) line: 339 PropertyChangeSupport.firePropertyChange(PropertyChangeEvent) line: 347 PropertyChangeSupport.firePropertyChange(String, Object, Object) line: 276
DefaultKeyboardFocusManager(KeyboardFocusManager).firePropertyChange(String, Object, Object) line: 1389 DefaultKeyboardFocusManager(KeyboardFocusManager).setGlobalPermanentFocusOwner(Component) line: 687 DefaultKeyboardFocusManager.dispatchEvent(AWTEvent) line: 490
JXMonthView(Component).dispatchEventImpl(AWTEvent) line: 4502
JXMonthView(Container).dispatchEventImpl(AWTEvent) line: 2099
JXMonthView(Component).dispatchEvent(AWTEvent) line: 4460
EventQueue.dispatchEvent(AWTEvent) line: 599
EventDispatchThread.pumpOneEventForFilters(int) line: 269
EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 184
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 174
EventDispatchThread.pumpEvents(int, Conditional) line: 169
EventDispatchThread.pumpEvents(Conditional) line: 161
EventDispatchThread.run() line: 122

A: 

Read the Swing tutorial on How to Use Tables. There is an example that uses a Color Chooser as a popop editor. The concept should be the same for a Data Chooser.

camickr