0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing;
0N/A
0N/Aimport java.awt.Component;
0N/Aimport java.awt.Container;
0N/Aimport java.awt.Rectangle;
0N/Aimport java.awt.event.PaintEvent;
0N/Aimport java.security.AccessController;
0N/Aimport sun.awt.AppContext;
0N/Aimport sun.awt.SunToolkit;
0N/Aimport sun.awt.event.IgnorePaintEvent;
0N/Aimport sun.security.action.GetBooleanAction;
0N/Aimport sun.security.action.GetPropertyAction;
0N/A
0N/A/**
0N/A * Swing's PaintEventDispatcher. If the component specified by the PaintEvent
0N/A * is a top level Swing component (JFrame, JWindow, JDialog, JApplet), this
0N/A * will forward the request to the RepaintManager for eventual painting.
0N/A *
0N/A */
0N/Aclass SwingPaintEventDispatcher extends sun.awt.PaintEventDispatcher {
0N/A private static final boolean SHOW_FROM_DOUBLE_BUFFER;
0N/A private static final boolean ERASE_BACKGROUND;
0N/A
0N/A static {
0N/A SHOW_FROM_DOUBLE_BUFFER = "true".equals(AccessController.doPrivileged(
0N/A new GetPropertyAction("swing.showFromDoubleBuffer", "true")));
0N/A ERASE_BACKGROUND = AccessController.doPrivileged(
0N/A new GetBooleanAction("swing.nativeErase"));
0N/A }
0N/A
0N/A public PaintEvent createPaintEvent(Component component, int x, int y,
0N/A int w, int h) {
0N/A if (component instanceof RootPaneContainer) {
0N/A AppContext appContext = SunToolkit.targetToAppContext(component);
0N/A RepaintManager rm = RepaintManager.currentManager(appContext);
0N/A if (!SHOW_FROM_DOUBLE_BUFFER ||
0N/A !rm.show((Container)component, x, y, w, h)) {
0N/A rm.nativeAddDirtyRegion(appContext, (Container)component,
0N/A x, y, w, h);
0N/A }
0N/A // For backward compatibility generate an empty paint
0N/A // event. Not doing this broke parts of Netbeans.
0N/A return new IgnorePaintEvent(component, PaintEvent.PAINT,
0N/A new Rectangle(x, y, w, h));
0N/A }
0N/A else if (component instanceof SwingHeavyWeight) {
0N/A AppContext appContext = SunToolkit.targetToAppContext(component);
0N/A RepaintManager rm = RepaintManager.currentManager(appContext);
0N/A rm.nativeAddDirtyRegion(appContext, (Container)component,
0N/A x, y, w, h);
0N/A return new IgnorePaintEvent(component, PaintEvent.PAINT,
0N/A new Rectangle(x, y, w, h));
0N/A }
0N/A return super.createPaintEvent(component, x, y, w, h);
0N/A }
0N/A
0N/A public boolean shouldDoNativeBackgroundErase(Component c) {
0N/A return ERASE_BACKGROUND || !(c instanceof RootPaneContainer);
0N/A }
0N/A
0N/A public boolean queueSurfaceDataReplacing(Component c, Runnable r) {
0N/A if (c instanceof RootPaneContainer) {
0N/A AppContext appContext = SunToolkit.targetToAppContext(c);
0N/A RepaintManager.currentManager(appContext).
0N/A nativeQueueSurfaceDataRunnable(appContext, c, r);
0N/A return true;
0N/A }
0N/A return super.queueSurfaceDataReplacing(c, r);
0N/A }
0N/A}
0N/A