mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
Invoker null check
This commit is contained in:
parent
c78ede2731
commit
91151bce29
@ -952,20 +952,21 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
|
|||||||
@BeanProperty(bound = false, expert = true, description
|
@BeanProperty(bound = false, expert = true, description
|
||||||
= "The invoking component for the popup menu")
|
= "The invoking component for the popup menu")
|
||||||
public void setInvoker(Component invoker) {
|
public void setInvoker(Component invoker) {
|
||||||
if (invoker != null) {
|
Component oldInvoker = this.invoker;
|
||||||
Component oldInvoker = this.invoker;
|
this.invoker = invoker;
|
||||||
this.invoker = invoker;
|
|
||||||
|
|
||||||
if ((oldInvoker != this.invoker) && (ui != null)) {
|
if ((oldInvoker != this.invoker) && (ui != null)) {
|
||||||
ui.uninstallUI(this);
|
ui.uninstallUI(this);
|
||||||
if (oldInvoker != null) {
|
if (oldInvoker != null) {
|
||||||
oldInvoker.removePropertyChangeListener("ancestor", propListener);
|
oldInvoker.removePropertyChangeListener("ancestor", propListener);
|
||||||
}
|
|
||||||
invoker.addPropertyChangeListener("ancestor", propListener);
|
|
||||||
ui.installUI(this);
|
|
||||||
}
|
}
|
||||||
invalidate();
|
if (invoker != null) {
|
||||||
|
invoker.addPropertyChangeListener("ancestor", propListener);
|
||||||
|
}
|
||||||
|
ui.installUI(this);
|
||||||
}
|
}
|
||||||
|
invalidate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -73,6 +73,7 @@ public class TestPopupInvoker {
|
|||||||
@Override
|
@Override
|
||||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||||
popupHidden.countDown();
|
popupHidden.countDown();
|
||||||
|
popupMenu.setInvoker(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,7 +109,6 @@ public class TestPopupInvoker {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
SwingUtilities.invokeAndWait(() -> {
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
popupMenu.setInvoker(null);
|
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user