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