1. /*
  2. * @(#)MultiListUI.java 1.26 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.ListUI;
  10. import javax.swing.JList;
  11. import java.awt.Point;
  12. import java.awt.Rectangle;
  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>ListUI</code>s.
  20. *
  21. * <p>This file was automatically generated by AutoMulti.
  22. *
  23. * @version 1.26 01/23/03 13:24:11
  24. * @author Otto Multey
  25. */
  26. public class MultiListUI extends ListUI {
  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. // ListUI methods
  47. ////////////////////
  48. /**
  49. * Invokes the <code>locationToIndex</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 int locationToIndex(JList a, Point b) {
  55. int returnValue =
  56. ((ListUI) (uis.elementAt(0))).locationToIndex(a,b);
  57. for (int i = 1; i < uis.size(); i++) {
  58. ((ListUI) (uis.elementAt(i))).locationToIndex(a,b);
  59. }
  60. return returnValue;
  61. }
  62. /**
  63. * Invokes the <code>indexToLocation</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 Point indexToLocation(JList a, int b) {
  69. Point returnValue =
  70. ((ListUI) (uis.elementAt(0))).indexToLocation(a,b);
  71. for (int i = 1; i < uis.size(); i++) {
  72. ((ListUI) (uis.elementAt(i))).indexToLocation(a,b);
  73. }
  74. return returnValue;
  75. }
  76. /**
  77. * Invokes the <code>getCellBounds</code> method on each UI handled by this object.
  78. *
  79. * @return the value obtained from the first UI, which is
  80. * the UI obtained from the default <code>LookAndFeel</code>
  81. */
  82. public Rectangle getCellBounds(JList a, int b, int c) {
  83. Rectangle returnValue =
  84. ((ListUI) (uis.elementAt(0))).getCellBounds(a,b,c);
  85. for (int i = 1; i < uis.size(); i++) {
  86. ((ListUI) (uis.elementAt(i))).getCellBounds(a,b,c);
  87. }
  88. return returnValue;
  89. }
  90. ////////////////////
  91. // ComponentUI methods
  92. ////////////////////
  93. /**
  94. * Invokes the <code>contains</code> method on each UI handled by this object.
  95. *
  96. * @return the value obtained from the first UI, which is
  97. * the UI obtained from the default <code>LookAndFeel</code>
  98. */
  99. public boolean contains(JComponent a, int b, int c) {
  100. boolean returnValue =
  101. ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
  102. for (int i = 1; i < uis.size(); i++) {
  103. ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
  104. }
  105. return returnValue;
  106. }
  107. /**
  108. * Invokes the <code>update</code> method on each UI handled by this object.
  109. */
  110. public void update(Graphics a, JComponent b) {
  111. for (int i = 0; i < uis.size(); i++) {
  112. ((ComponentUI) (uis.elementAt(i))).update(a,b);
  113. }
  114. }
  115. /**
  116. * Returns a multiplexing UI instance if any of the auxiliary
  117. * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the
  118. * UI object obtained from the default <code>LookAndFeel</code>.
  119. */
  120. public static ComponentUI createUI(JComponent a) {
  121. ComponentUI mui = new MultiListUI();
  122. return MultiLookAndFeel.createUIs(mui,
  123. ((MultiListUI) mui).uis,
  124. a);
  125. }
  126. /**
  127. * Invokes the <code>installUI</code> method on each UI handled by this object.
  128. */
  129. public void installUI(JComponent a) {
  130. for (int i = 0; i < uis.size(); i++) {
  131. ((ComponentUI) (uis.elementAt(i))).installUI(a);
  132. }
  133. }
  134. /**
  135. * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
  136. */
  137. public void uninstallUI(JComponent a) {
  138. for (int i = 0; i < uis.size(); i++) {
  139. ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
  140. }
  141. }
  142. /**
  143. * Invokes the <code>paint</code> method on each UI handled by this object.
  144. */
  145. public void paint(Graphics a, JComponent b) {
  146. for (int i = 0; i < uis.size(); i++) {
  147. ((ComponentUI) (uis.elementAt(i))).paint(a,b);
  148. }
  149. }
  150. /**
  151. * Invokes the <code>getPreferredSize</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 getPreferredSize(JComponent a) {
  157. Dimension returnValue =
  158. ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
  159. for (int i = 1; i < uis.size(); i++) {
  160. ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
  161. }
  162. return returnValue;
  163. }
  164. /**
  165. * Invokes the <code>getMinimumSize</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 getMinimumSize(JComponent a) {
  171. Dimension returnValue =
  172. ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
  173. for (int i = 1; i < uis.size(); i++) {
  174. ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
  175. }
  176. return returnValue;
  177. }
  178. /**
  179. * Invokes the <code>getMaximumSize</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 Dimension getMaximumSize(JComponent a) {
  185. Dimension returnValue =
  186. ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
  187. for (int i = 1; i < uis.size(); i++) {
  188. ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
  189. }
  190. return returnValue;
  191. }
  192. /**
  193. * Invokes the <code>getAccessibleChildrenCount</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 int getAccessibleChildrenCount(JComponent a) {
  199. int returnValue =
  200. ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
  201. for (int i = 1; i < uis.size(); i++) {
  202. ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
  203. }
  204. return returnValue;
  205. }
  206. /**
  207. * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
  208. *
  209. * @return the value obtained from the first UI, which is
  210. * the UI obtained from the default <code>LookAndFeel</code>
  211. */
  212. public Accessible getAccessibleChild(JComponent a, int b) {
  213. Accessible returnValue =
  214. ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
  215. for (int i = 1; i < uis.size(); i++) {
  216. ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
  217. }
  218. return returnValue;
  219. }
  220. }