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