< prev index next >

src/java.desktop/share/classes/java/awt/Component.java

Print this page




 826 
 827     // Whether this Component has had the background erase flag
 828     // specified via SunToolkit.disableBackgroundErase(). This is
 829     // needed in order to make this function work on X11 platforms,
 830     // where currently there is no chance to interpose on the creation
 831     // of the peer and therefore the call to XSetBackground.
 832     transient boolean backgroundEraseDisabled;
 833 
 834     static {
 835         AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
 836             public void setBackgroundEraseDisabled(Component comp, boolean disabled) {
 837                 comp.backgroundEraseDisabled = disabled;
 838             }
 839             public boolean getBackgroundEraseDisabled(Component comp) {
 840                 return comp.backgroundEraseDisabled;
 841             }
 842             public Rectangle getBounds(Component comp) {
 843                 return new Rectangle(comp.x, comp.y, comp.width, comp.height);
 844             }
 845             public void setMixingCutoutShape(Component comp, Shape shape) {
 846                 Region region = shape == null ?  null :
 847                     Region.getInstance(shape, null);
 848 
 849                 synchronized (comp.getTreeLock()) {
 850                     boolean needShowing = false;
 851                     boolean needHiding = false;
 852 
 853                     if (!comp.isNonOpaqueForMixing()) {
 854                         needHiding = true;
 855                     }
 856 
 857                     comp.mixingCutoutRegion = region;
 858 
 859                     if (!comp.isNonOpaqueForMixing()) {
 860                         needShowing = true;
 861                     }
 862 
 863                     if (comp.isMixingNeeded()) {
 864                         if (needHiding) {
 865                             comp.mixOnHiding(comp.isLightweight());
 866                         }
 867                         if (needShowing) {
 868                             comp.mixOnShowing();
 869                         }
 870                     }
 871                 }
 872             }
 873 
 874             public void setGraphicsConfiguration(Component comp,
 875                     GraphicsConfiguration gc)
 876             {
 877                 comp.setGraphicsConfiguration(gc);
 878             }
 879             public boolean requestFocus(Component comp, FocusEvent.Cause cause) {
 880                 return comp.requestFocus(cause);
 881             }
 882             public boolean canBeFocusOwner(Component comp) {
 883                 return comp.canBeFocusOwner();
 884             }
 885 
 886             public boolean isVisible(Component comp) {
 887                 return comp.isVisible_NoClientCode();
 888             }
 889             public void setRequestFocusController
 890                 (RequestFocusController requestController)
 891             {


10219             return false;
10220         }
10221         Window window = getContainingWindow();
10222         if (window != null) {
10223             if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants() || window.isDisposing()) {
10224                 if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
10225                     mixingLog.fine("containing window = " + window +
10226                             "; has h/w descendants = " + window.hasHeavyweightDescendants() +
10227                             "; has l/w descendants = " + window.hasLightweightDescendants() +
10228                             "; disposing = " + window.isDisposing());
10229                 }
10230                 return false;
10231             }
10232         } else {
10233             if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
10234                 mixingLog.fine("this = " + this + "; containing window is null");
10235             }
10236             return false;
10237         }
10238         return true;

































































10239     }
10240 
10241     // ****************** END OF MIXING CODE ********************************
10242 
10243     // Note that the method is overriden in the Window class,
10244     // a window doesn't need to be updated in the Z-order.
10245     void updateZOrder() {
10246         peer.setZOrder(getHWPeerAboveMe());
10247     }
10248 
10249 }


 826 
 827     // Whether this Component has had the background erase flag
 828     // specified via SunToolkit.disableBackgroundErase(). This is
 829     // needed in order to make this function work on X11 platforms,
 830     // where currently there is no chance to interpose on the creation
 831     // of the peer and therefore the call to XSetBackground.
 832     transient boolean backgroundEraseDisabled;
 833 
 834     static {
 835         AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
 836             public void setBackgroundEraseDisabled(Component comp, boolean disabled) {
 837                 comp.backgroundEraseDisabled = disabled;
 838             }
 839             public boolean getBackgroundEraseDisabled(Component comp) {
 840                 return comp.backgroundEraseDisabled;
 841             }
 842             public Rectangle getBounds(Component comp) {
 843                 return new Rectangle(comp.x, comp.y, comp.width, comp.height);
 844             }
 845             public void setMixingCutoutShape(Component comp, Shape shape) {
 846                 comp.setMixingCutoutShape(shape);

























 847             }
 848 
 849             public void setGraphicsConfiguration(Component comp,
 850                     GraphicsConfiguration gc)
 851             {
 852                 comp.setGraphicsConfiguration(gc);
 853             }
 854             public boolean requestFocus(Component comp, FocusEvent.Cause cause) {
 855                 return comp.requestFocus(cause);
 856             }
 857             public boolean canBeFocusOwner(Component comp) {
 858                 return comp.canBeFocusOwner();
 859             }
 860 
 861             public boolean isVisible(Component comp) {
 862                 return comp.isVisible_NoClientCode();
 863             }
 864             public void setRequestFocusController
 865                 (RequestFocusController requestController)
 866             {


10194             return false;
10195         }
10196         Window window = getContainingWindow();
10197         if (window != null) {
10198             if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants() || window.isDisposing()) {
10199                 if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
10200                     mixingLog.fine("containing window = " + window +
10201                             "; has h/w descendants = " + window.hasHeavyweightDescendants() +
10202                             "; has l/w descendants = " + window.hasLightweightDescendants() +
10203                             "; disposing = " + window.isDisposing());
10204                 }
10205                 return false;
10206             }
10207         } else {
10208             if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
10209                 mixingLog.fine("this = " + this + "; containing window is null");
10210             }
10211             return false;
10212         }
10213         return true;
10214     }
10215 
10216     /**
10217      * Sets a 'mixing-cutout' shape for the given component.
10218      *
10219      * By default a lightweight component is treated as an opaque rectangle for
10220      * the purposes of the Heavyweight/Lightweight Components Mixing feature.
10221      * This method enables developers to set an arbitrary shape to be cut out
10222      * from heavyweight components positioned underneath the lightweight
10223      * component in the z-order.
10224      * <p>
10225      * The {@code shape} argument may have the following values:
10226      * <ul>
10227      * <li>{@code null} - reverts the default cutout shape (the rectangle equal
10228      * to the component's {@code getBounds()})
10229      * <li><i>empty-shape</i> - does not cut out anything from heavyweight
10230      * components. This makes the given lightweight component effectively
10231      * transparent. Note that descendants of the lightweight component still
10232      * affect the shapes of heavyweight components.  An example of an
10233      * <i>empty-shape</i> is {@code new Rectangle()}.
10234      * <li><i>non-empty-shape</i> - the given shape will be cut out from
10235      * heavyweight components.
10236      * </ul>
10237      * <p>
10238      * The most common example when the 'mixing-cutout' shape is needed is a
10239      * glass pane component. The {@link JRootPane#setGlassPane()} method
10240      * automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape
10241      * for the given glass pane component.  If a developer needs some other
10242      * 'mixing-cutout' shape for the glass pane (which is rare), this must be
10243      * changed manually after installing the glass pane to the root pane.
10244      * <p>
10245      * Note that the 'mixing-cutout' shape neither affects painting, nor the
10246      * mouse events handling for the given component. It is used exclusively
10247      * for the purposes of the Heavyweight/Lightweight Components Mixing
10248      * feature.
10249      *
10250      * @param shape the new 'mixing-cutout' shape
10251      * @since 9
10252      */
10253     void setMixingCutoutShape(Shape shape) {
10254         Region region = shape == null ? null : Region.getInstance(shape, null);
10255 
10256         synchronized (getTreeLock()) {
10257             boolean needShowing = false;
10258             boolean needHiding = false;
10259 
10260             if (!isNonOpaqueForMixing()) {
10261                 needHiding = true;
10262             }
10263 
10264             mixingCutoutRegion = region;
10265 
10266             if (!isNonOpaqueForMixing()) {
10267                 needShowing = true;
10268             }
10269 
10270             if (isMixingNeeded()) {
10271                 if (needHiding) {
10272                     mixOnHiding(isLightweight());
10273                 }
10274                 if (needShowing) {
10275                     mixOnShowing();
10276                 }
10277             }
10278         }
10279     }
10280 
10281     // ****************** END OF MIXING CODE ********************************
10282 
10283     // Note that the method is overriden in the Window class,
10284     // a window doesn't need to be updated in the Z-order.
10285     void updateZOrder() {
10286         peer.setZOrder(getHWPeerAboveMe());
10287     }
10288 
10289 }
< prev index next >