mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8376169: JPopupMenu.setInvoker(null) causes NPE
This commit is contained in:
parent
0f087a7fef
commit
c47c5cb069
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -952,18 +952,20 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
|
||||
@BeanProperty(bound = false, expert = true, description
|
||||
= "The invoking component for the popup menu")
|
||||
public void setInvoker(Component invoker) {
|
||||
Component oldInvoker = this.invoker;
|
||||
this.invoker = invoker;
|
||||
if (invoker != null) {
|
||||
Component oldInvoker = this.invoker;
|
||||
this.invoker = invoker;
|
||||
|
||||
if ((oldInvoker != this.invoker) && (ui != null)) {
|
||||
ui.uninstallUI(this);
|
||||
if (oldInvoker != null) {
|
||||
oldInvoker.removePropertyChangeListener("ancestor", propListener);
|
||||
if ((oldInvoker != this.invoker) && (ui != null)) {
|
||||
ui.uninstallUI(this);
|
||||
if (oldInvoker != null) {
|
||||
oldInvoker.removePropertyChangeListener("ancestor", propListener);
|
||||
}
|
||||
invoker.addPropertyChangeListener("ancestor", propListener);
|
||||
ui.installUI(this);
|
||||
}
|
||||
invoker.addPropertyChangeListener("ancestor", propListener);
|
||||
ui.installUI(this);
|
||||
invalidate();
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -108,6 +108,7 @@ public class TestPopupInvoker {
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
popupMenu.setInvoker(null);
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user