1 7 package javax.swing; 8 9 import java.awt.Component ; 10 import java.awt.Container ; 11 import java.awt.Rectangle ; 12 import java.awt.event.PaintEvent ; 13 import java.security.AccessController ; 14 import sun.awt.AppContext; 15 import sun.awt.SunToolkit; 16 import sun.awt.event.IgnorePaintEvent; 17 import sun.security.action.GetBooleanAction; 18 import sun.security.action.GetPropertyAction; 19 20 27 class SwingPaintEventDispatcher extends sun.awt.PaintEventDispatcher { 28 private static final boolean SHOW_FROM_DOUBLE_BUFFER; 29 private static final boolean ERASE_BACKGROUND; 30 31 static { 32 SHOW_FROM_DOUBLE_BUFFER = "true".equals(AccessController.doPrivileged( 33 new GetPropertyAction("swing.showFromDoubleBuffer", "true"))); 34 ERASE_BACKGROUND = AccessController.doPrivileged( 35 new GetBooleanAction("swing.nativeErase")); 36 } 37 38 public PaintEvent createPaintEvent(Component component, int x, int y, 39 int w, int h) { 40 if (component instanceof RootPaneContainer ) { 41 AppContext appContext = SunToolkit.targetToAppContext(component); 42 RepaintManager rm = RepaintManager.currentManager(appContext); 43 if (!SHOW_FROM_DOUBLE_BUFFER || 44 !rm.show((Container )component, x, y, w, h)) { 45 rm.nativeAddDirtyRegion(appContext, (Container )component, 46 x, y, w, h); 47 } 48 return new IgnorePaintEvent(component, PaintEvent.PAINT, 51 new Rectangle (x, y, w, h)); 52 } 53 else if (component instanceof SwingHeavyWeight ) { 54 AppContext appContext = SunToolkit.targetToAppContext(component); 55 RepaintManager rm = RepaintManager.currentManager(appContext); 56 rm.nativeAddDirtyRegion(appContext, (Container )component, 57 x, y, w, h); 58 return new IgnorePaintEvent(component, PaintEvent.PAINT, 59 new Rectangle (x, y, w, h)); 60 } 61 return super.createPaintEvent(component, x, y, w, h); 62 } 63 64 public boolean shouldDoNativeBackgroundErase(Component c) { 65 return ERASE_BACKGROUND || !(c instanceof RootPaneContainer ); 66 } 67 68 public boolean queueSurfaceDataReplacing(Component c, Runnable r) { 69 if (c instanceof RootPaneContainer ) { 70 AppContext appContext = SunToolkit.targetToAppContext(c); 71 RepaintManager.currentManager(appContext). 72 nativeQueueSurfaceDataRunnable(appContext, c, r); 73 return true; 74 } 75 return super.queueSurfaceDataReplacing(c, r); 76 } 77 } 78 | Popular Tags |