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