001 /*
002 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.swing.plaf.multi;
026
027 import java.util.Vector;
028 import javax.swing.plaf.PopupMenuUI;
029 import java.awt.event.MouseEvent;
030 import javax.swing.Popup;
031 import javax.swing.JPopupMenu;
032 import javax.swing.plaf.ComponentUI;
033 import javax.swing.JComponent;
034 import java.awt.Graphics;
035 import java.awt.Dimension;
036 import javax.accessibility.Accessible;
037
038 /**
039 * A multiplexing UI used to combine <code>PopupMenuUI</code>s.
040 *
041 * <p>This file was automatically generated by AutoMulti.
042 *
043 * @version 1.36 05/05/07 17:20:40
044 * @author Otto Multey
045 */
046 public class MultiPopupMenuUI extends PopupMenuUI {
047
048 /**
049 * The vector containing the real UIs. This is populated
050 * in the call to <code>createUI</code>, and can be obtained by calling
051 * the <code>getUIs</code> method. The first element is guaranteed to be the real UI
052 * obtained from the default look and feel.
053 */
054 protected Vector uis = new Vector();
055
056 ////////////////////
057 // Common UI methods
058 ////////////////////
059
060 /**
061 * Returns the list of UIs associated with this multiplexing UI. This
062 * allows processing of the UIs by an application aware of multiplexing
063 * UIs on components.
064 */
065 public ComponentUI[] getUIs() {
066 return MultiLookAndFeel.uisToArray(uis);
067 }
068
069 ////////////////////
070 // PopupMenuUI methods
071 ////////////////////
072
073 /**
074 * Invokes the <code>isPopupTrigger</code> method on each UI handled by this object.
075 *
076 * @return the value obtained from the first UI, which is
077 * the UI obtained from the default <code>LookAndFeel</code>
078 * @since 1.3
079 */
080 public boolean isPopupTrigger(MouseEvent a) {
081 boolean returnValue = ((PopupMenuUI) (uis.elementAt(0)))
082 .isPopupTrigger(a);
083 for (int i = 1; i < uis.size(); i++) {
084 ((PopupMenuUI) (uis.elementAt(i))).isPopupTrigger(a);
085 }
086 return returnValue;
087 }
088
089 /**
090 * Invokes the <code>getPopup</code> method on each UI handled by this object.
091 *
092 * @return the value obtained from the first UI, which is
093 * the UI obtained from the default <code>LookAndFeel</code>
094 * @since 1.4
095 */
096 public Popup getPopup(JPopupMenu a, int b, int c) {
097 Popup returnValue = ((PopupMenuUI) (uis.elementAt(0)))
098 .getPopup(a, b, c);
099 for (int i = 1; i < uis.size(); i++) {
100 ((PopupMenuUI) (uis.elementAt(i))).getPopup(a, b, c);
101 }
102 return returnValue;
103 }
104
105 ////////////////////
106 // ComponentUI methods
107 ////////////////////
108
109 /**
110 * Invokes the <code>contains</code> method on each UI handled by this object.
111 *
112 * @return the value obtained from the first UI, which is
113 * the UI obtained from the default <code>LookAndFeel</code>
114 */
115 public boolean contains(JComponent a, int b, int c) {
116 boolean returnValue = ((ComponentUI) (uis.elementAt(0)))
117 .contains(a, b, c);
118 for (int i = 1; i < uis.size(); i++) {
119 ((ComponentUI) (uis.elementAt(i))).contains(a, b, c);
120 }
121 return returnValue;
122 }
123
124 /**
125 * Invokes the <code>update</code> method on each UI handled by this object.
126 */
127 public void update(Graphics a, JComponent b) {
128 for (int i = 0; i < uis.size(); i++) {
129 ((ComponentUI) (uis.elementAt(i))).update(a, b);
130 }
131 }
132
133 /**
134 * Returns a multiplexing UI instance if any of the auxiliary
135 * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the
136 * UI object obtained from the default <code>LookAndFeel</code>.
137 */
138 public static ComponentUI createUI(JComponent a) {
139 ComponentUI mui = new MultiPopupMenuUI();
140 return MultiLookAndFeel.createUIs(mui,
141 ((MultiPopupMenuUI) mui).uis, a);
142 }
143
144 /**
145 * Invokes the <code>installUI</code> method on each UI handled by this object.
146 */
147 public void installUI(JComponent a) {
148 for (int i = 0; i < uis.size(); i++) {
149 ((ComponentUI) (uis.elementAt(i))).installUI(a);
150 }
151 }
152
153 /**
154 * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
155 */
156 public void uninstallUI(JComponent a) {
157 for (int i = 0; i < uis.size(); i++) {
158 ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
159 }
160 }
161
162 /**
163 * Invokes the <code>paint</code> method on each UI handled by this object.
164 */
165 public void paint(Graphics a, JComponent b) {
166 for (int i = 0; i < uis.size(); i++) {
167 ((ComponentUI) (uis.elementAt(i))).paint(a, b);
168 }
169 }
170
171 /**
172 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
173 *
174 * @return the value obtained from the first UI, which is
175 * the UI obtained from the default <code>LookAndFeel</code>
176 */
177 public Dimension getPreferredSize(JComponent a) {
178 Dimension returnValue = ((ComponentUI) (uis.elementAt(0)))
179 .getPreferredSize(a);
180 for (int i = 1; i < uis.size(); i++) {
181 ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
182 }
183 return returnValue;
184 }
185
186 /**
187 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
188 *
189 * @return the value obtained from the first UI, which is
190 * the UI obtained from the default <code>LookAndFeel</code>
191 */
192 public Dimension getMinimumSize(JComponent a) {
193 Dimension returnValue = ((ComponentUI) (uis.elementAt(0)))
194 .getMinimumSize(a);
195 for (int i = 1; i < uis.size(); i++) {
196 ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
197 }
198 return returnValue;
199 }
200
201 /**
202 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
203 *
204 * @return the value obtained from the first UI, which is
205 * the UI obtained from the default <code>LookAndFeel</code>
206 */
207 public Dimension getMaximumSize(JComponent a) {
208 Dimension returnValue = ((ComponentUI) (uis.elementAt(0)))
209 .getMaximumSize(a);
210 for (int i = 1; i < uis.size(); i++) {
211 ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
212 }
213 return returnValue;
214 }
215
216 /**
217 * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object.
218 *
219 * @return the value obtained from the first UI, which is
220 * the UI obtained from the default <code>LookAndFeel</code>
221 */
222 public int getAccessibleChildrenCount(JComponent a) {
223 int returnValue = ((ComponentUI) (uis.elementAt(0)))
224 .getAccessibleChildrenCount(a);
225 for (int i = 1; i < uis.size(); i++) {
226 ((ComponentUI) (uis.elementAt(i)))
227 .getAccessibleChildrenCount(a);
228 }
229 return returnValue;
230 }
231
232 /**
233 * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
234 *
235 * @return the value obtained from the first UI, which is
236 * the UI obtained from the default <code>LookAndFeel</code>
237 */
238 public Accessible getAccessibleChild(JComponent a, int b) {
239 Accessible returnValue = ((ComponentUI) (uis.elementAt(0)))
240 .getAccessibleChild(a, b);
241 for (int i = 1; i < uis.size(); i++) {
242 ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a, b);
243 }
244 return returnValue;
245 }
246 }
|