001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.swing.plaf.multi;
019:
020: import java.awt.Dimension;
021: import java.awt.Graphics;
022: import java.util.Vector;
023:
024: import javax.accessibility.Accessible;
025: import javax.swing.JComponent;
026: import javax.swing.JOptionPane;
027: import javax.swing.plaf.ComponentUI;
028: import javax.swing.plaf.OptionPaneUI;
029:
030: /**
031: * All the methods described in public api
032: */
033: public class MultiOptionPaneUI extends OptionPaneUI {
034:
035: protected Vector uis = new Vector();
036:
037: /**
038: * Used in cycles. numberOfUIs = Correct number of UIs + 1, but the variable
039: * used in that sence
040: */
041: private int numberOfUIs;
042:
043: public static ComponentUI createUI(JComponent a) {
044: MultiOptionPaneUI mui = new MultiOptionPaneUI();
045: ComponentUI result = MultiLookAndFeel
046: .createUIs(mui, mui.uis, a);
047: mui.numberOfUIs = mui.uis.size();
048: return result;
049: }
050:
051: @Override
052: public boolean contains(JComponent a, int b, int c) {
053: for (int i = 1; i < numberOfUIs; i++) {
054: ((ComponentUI) uis.get(i)).contains(a, b, c);
055: }
056: return ((ComponentUI) uis.firstElement()).contains(a, b, c);
057: }
058:
059: @Override
060: public Accessible getAccessibleChild(JComponent a, int b) {
061: for (int i = 1; i < numberOfUIs; i++) {
062: ((ComponentUI) uis.get(i)).getAccessibleChild(a, b);
063: }
064: return ((ComponentUI) uis.firstElement()).getAccessibleChild(a,
065: b);
066: }
067:
068: @Override
069: public int getAccessibleChildrenCount(JComponent a) {
070: for (int i = 1; i < numberOfUIs; i++) {
071: ((ComponentUI) uis.get(i)).getAccessibleChildrenCount(a);
072: }
073: return ((ComponentUI) uis.firstElement())
074: .getAccessibleChildrenCount(a);
075: }
076:
077: @Override
078: public Dimension getMaximumSize(JComponent a) {
079: for (int i = 1; i < numberOfUIs; i++) {
080: ((ComponentUI) uis.get(i)).getMaximumSize(a);
081: }
082: return ((ComponentUI) uis.firstElement()).getMaximumSize(a);
083: }
084:
085: @Override
086: public Dimension getMinimumSize(JComponent a) {
087: for (int i = 1; i < numberOfUIs; i++) {
088: ((ComponentUI) uis.get(i)).getMinimumSize(a);
089: }
090: return ((ComponentUI) uis.firstElement()).getMinimumSize(a);
091: }
092:
093: @Override
094: public Dimension getPreferredSize(JComponent a) {
095: for (int i = 1; i < numberOfUIs; i++) {
096: ((ComponentUI) uis.get(i)).getPreferredSize(a);
097: }
098: return ((ComponentUI) uis.firstElement()).getPreferredSize(a);
099: }
100:
101: public ComponentUI[] getUIs() {
102: return MultiLookAndFeel.uisToArray(uis);
103: }
104:
105: @Override
106: public void installUI(JComponent a) {
107: for (Object ui : uis) {
108: ((ComponentUI) ui).installUI(a);
109: }
110: }
111:
112: @Override
113: public void paint(Graphics a, JComponent b) {
114: for (Object ui : uis) {
115: ((ComponentUI) ui).paint(a, b);
116: }
117: }
118:
119: @Override
120: public void uninstallUI(JComponent a) {
121: for (Object ui : uis) {
122: ((ComponentUI) ui).uninstallUI(a);
123: }
124: }
125:
126: @Override
127: public void update(Graphics a, JComponent b) {
128: for (Object ui : uis) {
129: ((ComponentUI) ui).update(a, b);
130: }
131: }
132:
133: @Override
134: public void selectInitialValue(JOptionPane op) {
135: for (Object ui : uis) {
136: ((OptionPaneUI) ui).selectInitialValue(op);
137: }
138:
139: }
140:
141: @Override
142: public boolean containsCustomComponents(JOptionPane op) {
143: for (int i = 1; i < numberOfUIs; i++) {
144: ((OptionPaneUI) uis.get(i)).containsCustomComponents(op);
145: }
146: return ((OptionPaneUI) uis.firstElement())
147: .containsCustomComponents(op);
148: }
149: }
|