1. /*
  2. * @(#)MultiMenuItemUI.java 1.23 01/11/29
  3. *
  4. * Copyright 2002 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. * MultiMenuItemUI implementation
  18. *
  19. * <p>This file was automatically generated by AutoMulti.
  20. *
  21. * @version 1.23 11/29/01 23:13:00
  22. * @author Otto Multey
  23. */
  24. public class MultiMenuItemUI extends MenuItemUI {
  25. /**
  26. * The Vector containing the real UI's. This is populated
  27. * in the call to createUI, and can be obtained by calling
  28. * getUIs. The first element is guaranteed to 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. * Return the list of UI's associated with this multiplexing UI. This
  37. * allows processing of the UI's by an application aware of multiplexing
  38. * UI's 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. * Call installUI on each UI handled by this MultiUI.
  54. */
  55. public void installUI(JComponent a) {
  56. for (int i = 0; i < uis.size(); i++) {
  57. ((ComponentUI) (uis.elementAt(i))).installUI(a);
  58. }
  59. }
  60. /**
  61. * Call uninstallUI on each UI handled by this MultiUI.
  62. */
  63. public void uninstallUI(JComponent a) {
  64. for (int i = 0; i < uis.size(); i++) {
  65. ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
  66. }
  67. }
  68. /**
  69. * Call paint on each UI handled by this MultiUI.
  70. */
  71. public void paint(Graphics a, JComponent b) {
  72. for (int i = 0; i < uis.size(); i++) {
  73. ((ComponentUI) (uis.elementAt(i))).paint(a,b);
  74. }
  75. }
  76. /**
  77. * Call update on each UI handled by this MultiUI.
  78. */
  79. public void update(Graphics a, JComponent b) {
  80. for (int i = 0; i < uis.size(); i++) {
  81. ((ComponentUI) (uis.elementAt(i))).update(a,b);
  82. }
  83. }
  84. /**
  85. * Call getPreferredSize on each UI handled by this MultiUI.
  86. * Return only the value obtained from the first UI, which is
  87. * the UI obtained from the default LookAndFeel.
  88. */
  89. public Dimension getPreferredSize(JComponent a) {
  90. Dimension returnValue =
  91. ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
  92. for (int i = 1; i < uis.size(); i++) {
  93. ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
  94. }
  95. return returnValue;
  96. }
  97. /**
  98. * Call getMinimumSize on each UI handled by this MultiUI.
  99. * Return only the value obtained from the first UI, which is
  100. * the UI obtained from the default LookAndFeel.
  101. */
  102. public Dimension getMinimumSize(JComponent a) {
  103. Dimension returnValue =
  104. ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
  105. for (int i = 1; i < uis.size(); i++) {
  106. ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
  107. }
  108. return returnValue;
  109. }
  110. /**
  111. * Call getMaximumSize on each UI handled by this MultiUI.
  112. * Return only the value obtained from the first UI, which is
  113. * the UI obtained from the default LookAndFeel.
  114. */
  115. public Dimension getMaximumSize(JComponent a) {
  116. Dimension returnValue =
  117. ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
  118. for (int i = 1; i < uis.size(); i++) {
  119. ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
  120. }
  121. return returnValue;
  122. }
  123. /**
  124. * Call contains on each UI handled by this MultiUI.
  125. * Return only the value obtained from the first UI, which is
  126. * the UI obtained from the default LookAndFeel.
  127. */
  128. public boolean contains(JComponent a, int b, int c) {
  129. boolean returnValue =
  130. ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
  131. for (int i = 1; i < uis.size(); i++) {
  132. ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
  133. }
  134. return returnValue;
  135. }
  136. /**
  137. * Return a multiplexing UI instance if any of the auxiliary
  138. * LookAndFeels support this UI. Otherwise, just return a
  139. * UI obtained using the normal methods.
  140. */
  141. public static ComponentUI createUI(JComponent a) {
  142. ComponentUI mui = new MultiMenuItemUI();
  143. return MultiLookAndFeel.createUIs(mui,
  144. ((MultiMenuItemUI) mui).uis,
  145. a);
  146. }
  147. /**
  148. * Call getAccessibleChildrenCount on each UI handled by this MultiUI.
  149. * Return only the value obtained from the first UI, which is
  150. * the UI obtained from the default LookAndFeel.
  151. */
  152. public int getAccessibleChildrenCount(JComponent a) {
  153. int returnValue =
  154. ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
  155. for (int i = 1; i < uis.size(); i++) {
  156. ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
  157. }
  158. return returnValue;
  159. }
  160. /**
  161. * Call getAccessibleChild on each UI handled by this MultiUI.
  162. * Return only the value obtained from the first UI, which is
  163. * the UI obtained from the default LookAndFeel.
  164. */
  165. public Accessible getAccessibleChild(JComponent a, int b) {
  166. Accessible returnValue =
  167. ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
  168. for (int i = 1; i < uis.size(); i++) {
  169. ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
  170. }
  171. return returnValue;
  172. }
  173. }