File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed
src/java.desktop/share/classes/javax/swing Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 1997, 2025 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997, 2026 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -952,18 +952,20 @@ && isVisible()) {
952952 @ BeanProperty (bound = false , expert = true , description
953953 = "The invoking component for the popup menu" )
954954 public void setInvoker (Component invoker ) {
955- Component oldInvoker = this .invoker ;
956- this .invoker = invoker ;
955+ if (invoker != null ) {
956+ Component oldInvoker = this .invoker ;
957+ this .invoker = invoker ;
957958
958- if ((oldInvoker != this .invoker ) && (ui != null )) {
959- ui .uninstallUI (this );
960- if (oldInvoker != null ) {
961- oldInvoker .removePropertyChangeListener ("ancestor" , propListener );
959+ if ((oldInvoker != this .invoker ) && (ui != null )) {
960+ ui .uninstallUI (this );
961+ if (oldInvoker != null ) {
962+ oldInvoker .removePropertyChangeListener ("ancestor" , propListener );
963+ }
964+ invoker .addPropertyChangeListener ("ancestor" , propListener );
965+ ui .installUI (this );
962966 }
963- invoker .addPropertyChangeListener ("ancestor" , propListener );
964- ui .installUI (this );
967+ invalidate ();
965968 }
966- invalidate ();
967969 }
968970
969971 /**
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -108,6 +108,7 @@ public static void main(String[] args) throws Exception {
108108 }
109109 } finally {
110110 SwingUtilities .invokeAndWait (() -> {
111+ popupMenu .setInvoker (null );
111112 if (frame != null ) {
112113 frame .dispose ();
113114 }
You can’t perform that action at this time.
0 commit comments