1 /*
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.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
109 final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
110 int n = cont.getComponentCount();
111 for(int i=0; i < n; i++) {
112 Component comp = cont.getComponent(i);
113 Color color = comp.getForeground();
114 if (color == null || color.equals(c)) {
115 ComponentPeer cpeer = acc.getPeer(comp);
116 if (cpeer != null) {
117 cpeer.setForeground(c);
118 }
119 if (cpeer instanceof LightweightPeer
120 && comp instanceof Container)
121 {
122 setForegroundForHierarchy((Container) comp, c);
123 }
124 }
125 }
126 }
127 }
128
129 /**
130 * DEPRECATED: Replaced by getInsets().
131 */
132 public Insets insets() {
133 return getInsets();
134 }
135
136 public void dispose() {
137 if (embedder != null) {
138 embedder.deinstall();
139 }
140 super.dispose();
141 }
142
143 protected boolean shouldFocusOnClick() {
144 // Return false if this container has children so in that case it won't
145 // be focused. Return true otherwise.
146 return ((Container)target).getComponentCount() == 0;
147 }
148 }
|
1 /*
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
109 final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
110 int n = cont.getComponentCount();
111 for(int i=0; i < n; i++) {
112 Component comp = cont.getComponent(i);
113 Color color = comp.getForeground();
114 if (color == null || color.equals(c)) {
115 ComponentPeer cpeer = acc.getPeer(comp);
116 if (cpeer != null) {
117 cpeer.setForeground(c);
118 }
119 if (cpeer instanceof LightweightPeer
120 && comp instanceof Container)
121 {
122 setForegroundForHierarchy((Container) comp, c);
123 }
124 }
125 }
126 }
127 }
128
129 public void dispose() {
130 if (embedder != null) {
131 embedder.deinstall();
132 }
133 super.dispose();
134 }
135
136 protected boolean shouldFocusOnClick() {
137 // Return false if this container has children so in that case it won't
138 // be focused. Return true otherwise.
139 return ((Container)target).getComponentCount() == 0;
140 }
141 }
|