1. /*
  2. * @(#)ComponentUI.java 1.18 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;
  11. import javax.swing.JComponent;
  12. import javax.swing.SwingUtilities;
  13. import javax.accessibility.Accessible;
  14. import java.awt.Container;
  15. import java.awt.Dimension;
  16. import java.awt.Graphics;
  17. import java.awt.Insets;
  18. public abstract class ComponentUI
  19. {
  20. public void installUI(JComponent c) {
  21. }
  22. public void uninstallUI(JComponent c) {
  23. }
  24. public void paint(Graphics g, JComponent c) {
  25. }
  26. public void update(Graphics g, JComponent c) {
  27. if (c.isOpaque()) {
  28. g.setColor(c.getBackground());
  29. g.fillRect(0, 0, c.getWidth(),c.getHeight());
  30. }
  31. paint(g, c);
  32. }
  33. public Dimension getPreferredSize(JComponent c) {
  34. return null;
  35. }
  36. public Dimension getMinimumSize(JComponent c) {
  37. return getPreferredSize(c);
  38. }
  39. public Dimension getMaximumSize(JComponent c) {
  40. return getPreferredSize(c);
  41. }
  42. public boolean contains(JComponent c, int x, int y) {
  43. return c.inside(x, y);
  44. }
  45. public static ComponentUI createUI(JComponent c) {
  46. throw new Error("ComponentUI.createUI not implemented.");
  47. }
  48. /**
  49. * Returns the number of accessible children in the object. If all
  50. * of the children of this object implement Accessible, than this
  51. * method should return the number of children of this object.
  52. * UI's might wish to override this if they present areas on the
  53. * screen that can be viewed as components, but actual components
  54. * are not used for presenting those areas.
  55. *
  56. * Note: as of the Java 2 platform v1.3, it is recommended that developers call
  57. * Component.AccessibleAWTComponent.getAccessibleChildrenCount() instead
  58. * of using this method.
  59. *
  60. * @see #getAccessibleChild
  61. * @return the number of accessible children in the object.
  62. */
  63. public int getAccessibleChildrenCount(JComponent c) {
  64. return SwingUtilities.getAccessibleChildrenCount(c);
  65. }
  66. /**
  67. * Return the nth Accessible child of the object.
  68. * UI's might wish to override this if they present areas on the
  69. * screen that can be viewed as components, but actual components
  70. * are not used for presenting those areas.
  71. *
  72. * Note: as of the Java 2 platform v1.3, it is recommended that developers call
  73. * Component.AccessibleAWTComponent.getAccessibleChild() instead
  74. * of using this method.
  75. *
  76. * @see #getAccessibleChildrenCount
  77. * @param i zero-based index of child
  78. * @return the nth Accessible child of the object
  79. */
  80. public Accessible getAccessibleChild(JComponent c, int i) {
  81. return SwingUtilities.getAccessibleChild(c, i);
  82. }
  83. }