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