jdk/src/java.desktop/unix/classes/sun/awt/X11/XPanelPeer.java
changeset 30469 bac0a7ff7e1e
parent 28231 b608ffcaed74
equal deleted inserted replaced
30468:a016d2637922 30469:bac0a7ff7e1e
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    25 package sun.awt.X11;
    25 package sun.awt.X11;
    26 
    26 
    27 import java.awt.*;
    27 import java.awt.*;
    28 import java.awt.peer.*;
    28 import java.awt.peer.*;
    29 
    29 
       
    30 import sun.awt.AWTAccessor;
       
    31 import sun.awt.AWTAccessor.ComponentAccessor;
    30 import sun.awt.SunGraphicsCallback;
    32 import sun.awt.SunGraphicsCallback;
    31 
    33 
    32 public class XPanelPeer extends XCanvasPeer implements PanelPeer {
    34 public class XPanelPeer extends XCanvasPeer implements PanelPeer {
    33 
    35 
    34     XEmbeddingContainer embedder = null; //new XEmbeddingContainer();
    36     XEmbeddingContainer embedder = null; //new XEmbeddingContainer();
    74                           SunGraphicsCallback.LIGHTWEIGHTS |
    76                           SunGraphicsCallback.LIGHTWEIGHTS |
    75                           SunGraphicsCallback.HEAVYWEIGHTS);
    77                           SunGraphicsCallback.HEAVYWEIGHTS);
    76 
    78 
    77     }
    79     }
    78 
    80 
    79     @SuppressWarnings("deprecation")
       
    80     public void setBackground(Color c) {
    81     public void setBackground(Color c) {
    81         Component comp;
    82         Component comp;
    82         int i;
    83         int i;
    83 
    84 
    84         Container cont = (Container) target;
    85         Container cont = (Container) target;
       
    86         final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    85         synchronized(target.getTreeLock()) {
    87         synchronized(target.getTreeLock()) {
    86             int n = cont.getComponentCount();
    88             int n = cont.getComponentCount();
    87             for(i=0; i < n; i++) {
    89             for(i=0; i < n; i++) {
    88                 comp = cont.getComponent(i);
    90                 comp = cont.getComponent(i);
    89                 ComponentPeer peer = comp.getPeer();
    91                 ComponentPeer peer = acc.getPeer(comp);
    90                 if (peer != null) {
    92                 if (peer != null) {
    91                     Color color = comp.getBackground();
    93                     Color color = comp.getBackground();
    92                     if (color == null || color.equals(c)) {
    94                     if (color == null || color.equals(c)) {
    93                         peer.setBackground(c);
    95                         peer.setBackground(c);
    94                     }
    96                     }
   100 
   102 
   101     public void setForeground(Color c) {
   103     public void setForeground(Color c) {
   102         setForegroundForHierarchy((Container) target, c);
   104         setForegroundForHierarchy((Container) target, c);
   103     }
   105     }
   104 
   106 
   105     @SuppressWarnings("deprecation")
       
   106     private void setForegroundForHierarchy(Container cont, Color c) {
   107     private void setForegroundForHierarchy(Container cont, Color c) {
   107         synchronized(target.getTreeLock()) {
   108         synchronized(target.getTreeLock()) {
       
   109             final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
   108             int n = cont.getComponentCount();
   110             int n = cont.getComponentCount();
   109             for(int i=0; i < n; i++) {
   111             for(int i=0; i < n; i++) {
   110                 Component comp = cont.getComponent(i);
   112                 Component comp = cont.getComponent(i);
   111                 Color color = comp.getForeground();
   113                 Color color = comp.getForeground();
   112                 if (color == null || color.equals(c)) {
   114                 if (color == null || color.equals(c)) {
   113                     ComponentPeer cpeer = comp.getPeer();
   115                     ComponentPeer cpeer = acc.getPeer(comp);
   114                     if (cpeer != null) {
   116                     if (cpeer != null) {
   115                         cpeer.setForeground(c);
   117                         cpeer.setForeground(c);
   116                     }
   118                     }
   117                     if (cpeer instanceof LightweightPeer
   119                     if (cpeer instanceof LightweightPeer
   118                         && comp instanceof Container)
   120                         && comp instanceof Container)