aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/Canvas.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/awt/Canvas.java')
-rw-r--r--libjava/java/awt/Canvas.java39
1 files changed, 38 insertions, 1 deletions
diff --git a/libjava/java/awt/Canvas.java b/libjava/java/awt/Canvas.java
index f6480e6..a4fe50f 100644
--- a/libjava/java/awt/Canvas.java
+++ b/libjava/java/awt/Canvas.java
@@ -8,8 +8,45 @@ details. */
package java.awt;
-/* A very incomplete placeholder. */
+import java.awt.peer.ComponentPeer;
public class Canvas extends Component
{
+ transient GraphicsConfiguration graphicsConfiguration;
+
+ public Canvas() { }
+
+ public Canvas(GraphicsConfiguration graphicsConfiguration)
+ {
+ this.graphicsConfiguration = graphicsConfiguration;
+ }
+
+ GraphicsConfiguration getGraphicsConfigurationImpl()
+ {
+ if (graphicsConfiguration != null)
+ return graphicsConfiguration;
+ return super.getGraphicsConfigurationImpl();
+ }
+
+ public void addNotify()
+ {
+ if (peer == null)
+ {
+ peer = (ComponentPeer) getToolkit().createCanvas(this);
+ }
+ super.addNotify();
+ }
+
+ /** Override this to create components with custom painting.
+ Defaults to filling the component with the background color. */
+ public void paint(Graphics gfx)
+ {
+ /* This implementation doesn't make much sense since the filling
+ of background color is guaranteed for heavyweight components
+ such as this. But there's no need to worry, since paint() is
+ usually overridden anyway. */
+ gfx.setColor(getBackground());
+ Dimension size = getSize();
+ gfx.fillRect(0, 0, size.width, size.height);
+ }
}