From ae4cedab6d373cf1f97578490207df8fa33c2770 Mon Sep 17 00:00:00 2001 From: anashaty Date: Tue, 18 Feb 2014 16:38:13 +0400 Subject: [PATCH] 7094099: DropDown List of JComboBox detached Reviewed-by: alexp, dcherepanov --- src/share/classes/javax/swing/MenuSelectionManager.java | 9 ++++++++- src/share/classes/sun/swing/SwingUtilities2.java | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/share/classes/javax/swing/MenuSelectionManager.java b/src/share/classes/javax/swing/MenuSelectionManager.java index 1f6ac77aa..3f83acbac 100644 --- a/src/share/classes/javax/swing/MenuSelectionManager.java +++ b/src/share/classes/javax/swing/MenuSelectionManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, 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 @@ -30,6 +30,7 @@ import java.awt.event.*; import javax.swing.event.*; import sun.awt.AppContext; +import sun.swing.SwingUtilities2; /** * A MenuSelectionManager owns the selection in menu hierarchy. @@ -60,6 +61,12 @@ public class MenuSelectionManager { if (msm == null) { msm = new MenuSelectionManager(); context.put(MENU_SELECTION_MANAGER_KEY, msm); + + // installing additional listener if found in the AppContext + Object o = context.get(SwingUtilities2.MENU_SELECTION_MANAGER_LISTENER_KEY); + if (o != null && o instanceof ChangeListener) { + msm.addChangeListener((ChangeListener) o); + } } return msm; diff --git a/src/share/classes/sun/swing/SwingUtilities2.java b/src/share/classes/sun/swing/SwingUtilities2.java index 8b79b5e53..f36d43398 100644 --- a/src/share/classes/sun/swing/SwingUtilities2.java +++ b/src/share/classes/sun/swing/SwingUtilities2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, 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 @@ -81,6 +81,9 @@ public class SwingUtilities2 { public static final Object LAF_STATE_KEY = new StringBuffer("LookAndFeel State"); + public static final Object MENU_SELECTION_MANAGER_LISTENER_KEY = + new StringBuffer("MenuSelectionManager listener key"); + // Maintain a cache of CACHE_SIZE fonts and the left side bearing // of the characters falling into the range MIN_CHAR_INDEX to // MAX_CHAR_INDEX. The values in fontCache are created as needed. -- GitLab