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