4632N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4632N/A * This code is free software; you can redistribute it and/or modify it 4632N/A * under the terms of the GNU General Public License version 2 only, as 4632N/A * published by the Free Software Foundation. Oracle designates this 4632N/A * particular file as subject to the "Classpath" exception as provided 4632N/A * by Oracle in the LICENSE file that accompanied this code. 4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4632N/A * version 2 for more details (a copy is included in the LICENSE file that 4632N/A * You should have received a copy of the GNU General Public License version 4632N/A * 2 along with this work; if not, write to the Free Software Foundation, 4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4632N/A * or visit www.oracle.com if you need additional information or have any 4632N/A * The JRootPane manages the default button. There can be only one active rootpane, 4632N/A * and one default button, so we need only one timer 4632N/A * AquaRootPaneUI is a singleton object 4632N/A // for <rdar://problem/3689020> REGR: Realtime LAF updates no longer work 4632N/A // because the JFrame parent has a LAF background set (why without a UI element I don't know!) 4632N/A // we have to set it from the root pane so when we are coming from metal we will set it to 4632N/A // This is because the aqua color is a magical color that gets the background of the window, 4632N/A // so for most other LAFs the root pane changing is enough since it would be opaque, but for us 4632N/A // it is not since we are going to grab the one that was set on the JFrame. :( 4632N/A // for <rdar://problem/3750909> OutOfMemoryError swapping menus. 4632N/A * If the screen menu bar is active we need to listen to the layered pane of the root pane 4632N/A * because it holds the JMenuBar. So, if a new layered pane was added, listen to it. 4632N/A * If a new JMenuBar was added, tell the menu bar UI, because it will need to update the menu bar. 4632N/A // Could be a JDialog, and may have been added to a JRootPane not yet in a window. 4632N/A * Likewise, when the layered pane is removed from the root pane, stop listening to it. 4632N/A * If the JMenuBar is removed, tell the menu bar UI to clear the menu bar. 4632N/A // Could be a JDialog, and may have been added to a JRootPane not yet in a window. 4632N/A * Invoked when a property changes on the root pane. If the event 4632N/A * indicates the <code>defaultButton</code> has changed, this will 4632N/A * If the enabled state changed, it will start or stop the animation 4632N/A // Change the animating button if this root is showing and enabled 4632N/A // otherwise do nothing - someone else may be active 4632N/A //System.err.println("in updateDefaultButton button = " + button); 4632N/A * This is sort of like viewDidMoveToWindow:. When the root pane is put into a window 4632N/A * this method gets called for the notification. 4632N/A * We need to set up the listener relationship so we can pick up activation events. 4632N/A * And, if a JMenuBar was added before the root pane was added to the window, we now need 4632N/A * to notify the menu bar UI. 4632N/A // this is so we can handle window activated and deactivated events so 4632N/A // We get this message even when a dialog is opened and the owning window is a window 4632N/A // that could already be listened to. We should only be a listener once. 4632N/A // adding multiple listeners was the cause of <rdar://problem/3534047> 4632N/A // but the incorrect removal of them caused <rdar://problem/3617848> 4632N/A // The root pane has been added to the hierarchy. If it's enabled update the default 4632N/A // button to start the throbbing. Since the UI is a singleton make sure the root pane 4632N/A // we are checking has a default button before calling update otherwise we will stop 4632N/A // throbbing the current default button. 4632N/A * If the JRootPane was removed from the window we should clear the screen menu bar. 4632N/A * That's a non-trivial problem, because you need to know which window the JRootPane was in 4632N/A * before it was removed. By the time ancestorRemoved was called, the JRootPane has already been removed 4632N/A // We know the window is closed so remove the listener.