1. /*
  2. * @(#)MultiListUI.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.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. * MultiListUI implementation
  20. *
  21. * <p>This file was automatically generated by AutoMulti.
  22. *
  23. * @version 1.22 11/29/01 23:12:58
  24. * @author Otto Multey
  25. */
  26. public class MultiListUI extends ListUI {
  27. /**
  28. * The Vector containing the real UI's. This is populated
  29. * in the call to createUI, and can be obtained by calling
  30. * getUIs. The first element is guaranteed to 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. * Return the list of UI's associated with this multiplexing UI. This
  39. * allows processing of the UI's by an application aware of multiplexing
  40. * UI's on components.
  41. */
  42. public ComponentUI[] getUIs() {
  43. return MultiLookAndFeel.uisToArray(uis);
  44. }
  45. ////////////////////
  46. // ListUI methods
  47. ////////////////////
  48. /**
  49. * Call locationToIndex on each UI handled by this MultiUI.
  50. * Return only the value obtained from the first UI, which is
  51. * the UI obtained from the default LookAndFeel.
  52. */
  53. public int locationToIndex(JList a, Point b) {
  54. int returnValue =
  55. ((ListUI) (uis.elementAt(0))).locationToIndex(a,b);
  56. for (int i = 1; i < uis.size(); i++) {
  57. ((ListUI) (uis.elementAt(i))).locationToIndex(a,b);
  58. }
  59. return returnValue;
  60. }
  61. /**
  62. * Call indexToLocation on each UI handled by this MultiUI.
  63. * Return only the value obtained from the first UI, which is
  64. * the UI obtained from the default LookAndFeel.
  65. */
  66. public Point indexToLocation(JList a, int b) {
  67. Point returnValue =
  68. ((ListUI) (uis.elementAt(0))).indexToLocation(a,b);
  69. for (int i = 1; i < uis.size(); i++) {
  70. ((ListUI) (uis.elementAt(i))).indexToLocation(a,b);
  71. }
  72. return returnValue;
  73. }
  74. /**
  75. * Call getCellBounds on each UI handled by this MultiUI.
  76. * Return only the value obtained from the first UI, which is
  77. * the UI obtained from the default LookAndFeel.
  78. */
  79. public Rectangle getCellBounds(JList a, int b, int c) {
  80. Rectangle returnValue =
  81. ((ListUI) (uis.elementAt(0))).getCellBounds(a,b,c);
  82. for (int i = 1; i < uis.size(); i++) {
  83. ((ListUI) (uis.elementAt(i))).getCellBounds(a,b,c);
  84. }
  85. return returnValue;
  86. }
  87. ////////////////////
  88. // ComponentUI methods
  89. ////////////////////
  90. /**
  91. * Call installUI on each UI handled by this MultiUI.
  92. */
  93. public void installUI(JComponent a) {
  94. for (int i = 0; i < uis.size(); i++) {
  95. ((ComponentUI) (uis.elementAt(i))).installUI(a);
  96. }
  97. }
  98. /**
  99. * Call uninstallUI on each UI handled by this MultiUI.
  100. */
  101. public void uninstallUI(JComponent a) {
  102. for (int i = 0; i < uis.size(); i++) {
  103. ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
  104. }
  105. }
  106. /**
  107. * Call paint on each UI handled by this MultiUI.
  108. */
  109. public void paint(Graphics a, JComponent b) {
  110. for (int i = 0; i < uis.size(); i++) {
  111. ((ComponentUI) (uis.elementAt(i))).paint(a,b);
  112. }
  113. }
  114. /**
  115. * Call update on each UI handled by this MultiUI.
  116. */
  117. public void update(Graphics a, JComponent b) {
  118. for (int i = 0; i < uis.size(); i++) {
  119. ((ComponentUI) (uis.elementAt(i))).update(a,b);
  120. }
  121. }
  122. /**
  123. * Call getPreferredSize on each UI handled by this MultiUI.
  124. * Return only the value obtained from the first UI, which is
  125. * the UI obtained from the default LookAndFeel.
  126. */
  127. public Dimension getPreferredSize(JComponent a) {
  128. Dimension returnValue =
  129. ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
  130. for (int i = 1; i < uis.size(); i++) {
  131. ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
  132. }
  133. return returnValue;
  134. }
  135. /**
  136. * Call getMinimumSize on each UI handled by this MultiUI.
  137. * Return only the value obtained from the first UI, which is
  138. * the UI obtained from the default LookAndFeel.
  139. */
  140. public Dimension getMinimumSize(JComponent a) {
  141. Dimension returnValue =
  142. ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
  143. for (int i = 1; i < uis.size(); i++) {
  144. ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
  145. }
  146. return returnValue;
  147. }
  148. /**
  149. * Call getMaximumSize on each UI handled by this MultiUI.
  150. * Return only the value obtained from the first UI, which is
  151. * the UI obtained from the default LookAndFeel.
  152. */
  153. public Dimension getMaximumSize(JComponent a) {
  154. Dimension returnValue =
  155. ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
  156. for (int i = 1; i < uis.size(); i++) {
  157. ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
  158. }
  159. return returnValue;
  160. }
  161. /**
  162. * Call contains on each UI handled by this MultiUI.
  163. * Return only the value obtained from the first UI, which is
  164. * the UI obtained from the default LookAndFeel.
  165. */
  166. public boolean contains(JComponent a, int b, int c) {
  167. boolean returnValue =
  168. ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
  169. for (int i = 1; i < uis.size(); i++) {
  170. ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
  171. }
  172. return returnValue;
  173. }
  174. /**
  175. * Return a multiplexing UI instance if any of the auxiliary
  176. * LookAndFeels support this UI. Otherwise, just return a
  177. * UI obtained using the normal methods.
  178. */
  179. public static ComponentUI createUI(JComponent a) {
  180. ComponentUI mui = new MultiListUI();
  181. return MultiLookAndFeel.createUIs(mui,
  182. ((MultiListUI) mui).uis,
  183. a);
  184. }
  185. /**
  186. * Call getAccessibleChildrenCount on each UI handled by this MultiUI.
  187. * Return only the value obtained from the first UI, which is
  188. * the UI obtained from the default LookAndFeel.
  189. */
  190. public int getAccessibleChildrenCount(JComponent a) {
  191. int returnValue =
  192. ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
  193. for (int i = 1; i < uis.size(); i++) {
  194. ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
  195. }
  196. return returnValue;
  197. }
  198. /**
  199. * Call getAccessibleChild on each UI handled by this MultiUI.
  200. * Return only the value obtained from the first UI, which is
  201. * the UI obtained from the default LookAndFeel.
  202. */
  203. public Accessible getAccessibleChild(JComponent a, int b) {
  204. Accessible returnValue =
  205. ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
  206. for (int i = 1; i < uis.size(); i++) {
  207. ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
  208. }
  209. return returnValue;
  210. }
  211. }