1. /*
  2. * @(#)ComponentPeer.java 1.48 04/06/08
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.peer;
  8. import java.awt.*;
  9. import java.awt.event.PaintEvent;
  10. import java.awt.image.ImageProducer;
  11. import java.awt.image.ImageObserver;
  12. import java.awt.image.ColorModel;
  13. import java.awt.image.VolatileImage;
  14. import java.awt.GraphicsConfiguration;
  15. import java.awt.dnd.peer.DropTargetPeer;
  16. /**
  17. * The peer interfaces are intended only for use in porting
  18. * the AWT. They are not intended for use by application
  19. * developers, and developers should not implement peers
  20. * nor invoke any of the peer methods directly on the peer
  21. * instances.
  22. */
  23. public interface ComponentPeer {
  24. public static final int SET_LOCATION = 1,
  25. SET_SIZE = 2,
  26. SET_BOUNDS = 3,
  27. SET_CLIENT_SIZE = 4,
  28. RESET_OPERATION = 5,
  29. NO_EMBEDDED_CHECK = (1 << 14),
  30. DEFAULT_OPERATION = SET_BOUNDS;
  31. boolean isObscured();
  32. boolean canDetermineObscurity();
  33. void setVisible(boolean b);
  34. void setEnabled(boolean b);
  35. void paint(Graphics g);
  36. void repaint(long tm, int x, int y, int width, int height);
  37. void print(Graphics g);
  38. void setBounds(int x, int y, int width, int height, int op);
  39. void handleEvent(AWTEvent e);
  40. void coalescePaintEvent(PaintEvent e);
  41. Point getLocationOnScreen();
  42. Dimension getPreferredSize();
  43. Dimension getMinimumSize();
  44. ColorModel getColorModel();
  45. Toolkit getToolkit();
  46. Graphics getGraphics();
  47. FontMetrics getFontMetrics(Font font);
  48. void dispose();
  49. void setForeground(Color c);
  50. void setBackground(Color c);
  51. void setFont(Font f);
  52. void updateCursorImmediately();
  53. boolean requestFocus(Component lightweightChild,
  54. boolean temporary,
  55. boolean focusedWindowChangeAllowed,
  56. long time);
  57. boolean isFocusable();
  58. Image createImage(ImageProducer producer);
  59. Image createImage(int width, int height);
  60. VolatileImage createVolatileImage(int width, int height);
  61. boolean prepareImage(Image img, int w, int h, ImageObserver o);
  62. int checkImage(Image img, int w, int h, ImageObserver o);
  63. GraphicsConfiguration getGraphicsConfiguration();
  64. boolean handlesWheelScrolling();
  65. void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
  66. Image getBackBuffer();
  67. void flip(BufferCapabilities.FlipContents flipAction);
  68. void destroyBuffers();
  69. /**
  70. * Reparents this peer to the new parent referenced by <code>newContainer</code> peer
  71. * Implementation depends on toolkit and container.
  72. * @param newContainer peer of the new parent container
  73. * @since 1.5
  74. */
  75. void reparent(ContainerPeer newContainer);
  76. /**
  77. * Returns whether this peer supports reparenting to another parent withour destroying the peer
  78. * @return true if appropriate reparent is supported, false otherwise
  79. * @since 1.5
  80. */
  81. boolean isReparentSupported();
  82. /**
  83. * Used by lightweight implementations to tell a ComponentPeer to layout
  84. * its sub-elements. For instance, a lightweight Checkbox needs to layout
  85. * the box, as well as the text label.
  86. */
  87. void layout();
  88. Rectangle getBounds();
  89. /**
  90. * DEPRECATED: Replaced by getPreferredSize().
  91. */
  92. Dimension preferredSize();
  93. /**
  94. * DEPRECATED: Replaced by getMinimumSize().
  95. */
  96. Dimension minimumSize();
  97. /**
  98. * DEPRECATED: Replaced by setVisible(boolean).
  99. */
  100. void show();
  101. /**
  102. * DEPRECATED: Replaced by setVisible(boolean).
  103. */
  104. void hide();
  105. /**
  106. * DEPRECATED: Replaced by setEnabled(boolean).
  107. */
  108. void enable();
  109. /**
  110. * DEPRECATED: Replaced by setEnabled(boolean).
  111. */
  112. void disable();
  113. /**
  114. * DEPRECATED: Replaced by setBounds(int, int, int, int).
  115. */
  116. void reshape(int x, int y, int width, int height);
  117. }