1. /*
  2. * @(#)MultiPopupMenuUI.java 1.28 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.multi;
  8. import java.util.Vector;
  9. import javax.swing.plaf.PopupMenuUI;
  10. import java.awt.event.MouseEvent;
  11. import javax.swing.Popup;
  12. import javax.swing.JPopupMenu;
  13. import javax.swing.plaf.ComponentUI;
  14. import javax.swing.JComponent;
  15. import java.awt.Graphics;
  16. import java.awt.Dimension;
  17. import javax.accessibility.Accessible;
  18. /**
  19. * A multiplexing UI used to combine <code>PopupMenuUI</code>s.
  20. *
  21. * <p>This file was automatically generated by AutoMulti.
  22. *
  23. * @version 1.28 12/19/03 17:39:37
  24. * @author Otto Multey
  25. */
  26. public class MultiPopupMenuUI extends PopupMenuUI {
  27. /**
  28. * The vector containing the real UIs. This is populated
  29. * in the call to <code>createUI</code>, and can be obtained by calling
  30. * the <code>getUIs</code> method. The first element is guaranteed to be the real UI
  31. * obtained from the default look and feel.
  32. */
  33. protected Vector uis = new Vector();
  34. ////////////////////
  35. // Common UI methods
  36. ////////////////////
  37. /**
  38. * Returns the list of UIs associated with this multiplexing UI. This
  39. * allows processing of the UIs by an application aware of multiplexing
  40. * UIs on components.
  41. */
  42. public ComponentUI[] getUIs() {
  43. return MultiLookAndFeel.uisToArray(uis);
  44. }
  45. ////////////////////
  46. // PopupMenuUI methods
  47. ////////////////////
  48. /**
  49. * Invokes the <code>isPopupTrigger</code> method on each UI handled by this object.
  50. *
  51. * @return the value obtained from the first UI, which is
  52. * the UI obtained from the default <code>LookAndFeel</code>
  53. */
  54. public boolean isPopupTrigger(MouseEvent a) {
  55. boolean returnValue =
  56. ((PopupMenuUI) (uis.elementAt(0))).isPopupTrigger(a);
  57. for (int i = 1; i < uis.size(); i++) {
  58. ((PopupMenuUI) (uis.elementAt(i))).isPopupTrigger(a);
  59. }
  60. return returnValue;
  61. }
  62. /**
  63. * Invokes the <code>getPopup</code> method on each UI handled by this object.
  64. *
  65. * @return the value obtained from the first UI, which is
  66. * the UI obtained from the default <code>LookAndFeel</code>
  67. */
  68. public Popup getPopup(JPopupMenu a, int b, int c) {
  69. Popup returnValue =
  70. ((PopupMenuUI) (uis.elementAt(0))).getPopup(a,b,c);
  71. for (int i = 1; i < uis.size(); i++) {
  72. ((PopupMenuUI) (uis.elementAt(i))).getPopup(a,b,c);
  73. }
  74. return returnValue;
  75. }
  76. ////////////////////
  77. // ComponentUI methods
  78. ////////////////////
  79. /**
  80. * Invokes the <code>contains</code> method on each UI handled by this object.
  81. *
  82. * @return the value obtained from the first UI, which is
  83. * the UI obtained from the default <code>LookAndFeel</code>
  84. */
  85. public boolean contains(JComponent a, int b, int c) {
  86. boolean returnValue =
  87. ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
  88. for (int i = 1; i < uis.size(); i++) {
  89. ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
  90. }
  91. return returnValue;
  92. }
  93. /**
  94. * Invokes the <code>update</code> method on each UI handled by this object.
  95. */
  96. public void update(Graphics a, JComponent b) {
  97. for (int i = 0; i < uis.size(); i++) {
  98. ((ComponentUI) (uis.elementAt(i))).update(a,b);
  99. }
  100. }
  101. /**
  102. * Returns a multiplexing UI instance if any of the auxiliary
  103. * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the
  104. * UI object obtained from the default <code>LookAndFeel</code>.
  105. */
  106. public static ComponentUI createUI(JComponent a) {
  107. ComponentUI mui = new MultiPopupMenuUI();
  108. return MultiLookAndFeel.createUIs(mui,
  109. ((MultiPopupMenuUI) mui).uis,
  110. a);
  111. }
  112. /**
  113. * Invokes the <code>installUI</code> method on each UI handled by this object.
  114. */
  115. public void installUI(JComponent a) {
  116. for (int i = 0; i < uis.size(); i++) {
  117. ((ComponentUI) (uis.elementAt(i))).installUI(a);
  118. }
  119. }
  120. /**
  121. * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
  122. */
  123. public void uninstallUI(JComponent a) {
  124. for (int i = 0; i < uis.size(); i++) {
  125. ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
  126. }
  127. }
  128. /**
  129. * Invokes the <code>paint</code> method on each UI handled by this object.
  130. */
  131. public void paint(Graphics a, JComponent b) {
  132. for (int i = 0; i < uis.size(); i++) {
  133. ((ComponentUI) (uis.elementAt(i))).paint(a,b);
  134. }
  135. }
  136. /**
  137. * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
  138. *
  139. * @return the value obtained from the first UI, which is
  140. * the UI obtained from the default <code>LookAndFeel</code>
  141. */
  142. public Dimension getPreferredSize(JComponent a) {
  143. Dimension returnValue =
  144. ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
  145. for (int i = 1; i < uis.size(); i++) {
  146. ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
  147. }
  148. return returnValue;
  149. }
  150. /**
  151. * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
  152. *
  153. * @return the value obtained from the first UI, which is
  154. * the UI obtained from the default <code>LookAndFeel</code>
  155. */
  156. public Dimension getMinimumSize(JComponent a) {
  157. Dimension returnValue =
  158. ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
  159. for (int i = 1; i < uis.size(); i++) {
  160. ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
  161. }
  162. return returnValue;
  163. }
  164. /**
  165. * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
  166. *
  167. * @return the value obtained from the first UI, which is
  168. * the UI obtained from the default <code>LookAndFeel</code>
  169. */
  170. public Dimension getMaximumSize(JComponent a) {
  171. Dimension returnValue =
  172. ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
  173. for (int i = 1; i < uis.size(); i++) {
  174. ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
  175. }
  176. return returnValue;
  177. }
  178. /**
  179. * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object.
  180. *
  181. * @return the value obtained from the first UI, which is
  182. * the UI obtained from the default <code>LookAndFeel</code>
  183. */
  184. public int getAccessibleChildrenCount(JComponent a) {
  185. int returnValue =
  186. ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
  187. for (int i = 1; i < uis.size(); i++) {
  188. ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
  189. }
  190. return returnValue;
  191. }
  192. /**
  193. * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
  194. *
  195. * @return the value obtained from the first UI, which is
  196. * the UI obtained from the default <code>LookAndFeel</code>
  197. */
  198. public Accessible getAccessibleChild(JComponent a, int b) {
  199. Accessible returnValue =
  200. ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
  201. for (int i = 1; i < uis.size(); i++) {
  202. ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
  203. }
  204. return returnValue;
  205. }
  206. }