fix listener adding/removal

This commit is contained in:
millmanorama 2018-03-26 14:06:48 +02:00
parent 78f1028875
commit d98eabb22d
2 changed files with 20 additions and 4 deletions

View File

@ -118,10 +118,6 @@ public final class MessageBrowser extends JPanel implements ExplorerManager.Prov
Bundle.MessageBrowser_DataResultViewerTable_title()));
messagesResultPanel.open();
//add listener that maintains correct selection in the Global Actions Context
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener("focusOwner", focusPropertyListener);
this.tableEM.addPropertyChangeListener(new PropertyChangeListener() {
/**
* Listener that pushes selections in the tableEM (the Accounts
@ -176,6 +172,14 @@ public final class MessageBrowser extends JPanel implements ExplorerManager.Prov
return proxyLookup;
}
@Override
public void addNotify() {
super.addNotify();
//add listener that maintains correct selection in the Global Actions Context
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener("focusOwner", focusPropertyListener);
}
@Override
public void removeNotify() {
super.removeNotify();

View File

@ -446,6 +446,17 @@ public final class TimeLineTopComponent extends TopComponent implements Explorer
public void componentOpened() {
super.componentOpened();
WindowManager.getDefault().setTopComponentFloating(this, true);
//add listener that maintains correct selection in the Global Actions Context
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener("focusOwner", focusPropertyListener);
}
@Override
protected void componentClosed() {
super.componentClosed();
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removePropertyChangeListener("focusOwner", focusPropertyListener);
}
@Override
@ -476,6 +487,7 @@ public final class TimeLineTopComponent extends TopComponent implements Explorer
.withZone(TimeLineController.getJodaTimeZone())
.toString(zonedFormatter);
return Bundle.TimeLineResultView_startDateToEndDate_text(start, end);
}
}