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