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