Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2012-01-26 14:29:38 -0500
committerCarolyn MacLeod2012-01-26 14:29:38 -0500
commit6f1d087b428a735c63b7cb023a054ebc44beff72 (patch)
tree6630dbc7ffa839edff0331913d86c9e2a8432948 /examples
parent934aa196b8c3a5a2b8cbbdf32ca385793f69de82 (diff)
downloadeclipse.platform.swt-6f1d087b428a735c63b7cb023a054ebc44beff72.tar.gz
eclipse.platform.swt-6f1d087b428a735c63b7cb023a054ebc44beff72.tar.xz
eclipse.platform.swt-6f1d087b428a735c63b7cb023a054ebc44beff72.zip
fill Canvas background with white before drawing
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java
index cb4d7a3c85..d619394380 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java
@@ -19,6 +19,7 @@ package org.eclipse.swt.snippets;
*
* @since 3.8
*/
+import java.awt.Color;
import java.awt.Frame;
import java.awt.Canvas;
import java.awt.Graphics;
@@ -102,9 +103,7 @@ public class Snippet361 {
printButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Rectangle r = composite.getBounds();
- System.out.println(r);
Point p = shell.toDisplay(r.x, r.y);
- System.out.println(p);
org.eclipse.swt.graphics.Image snapshotImage
= new org.eclipse.swt.graphics.Image(display, r.width-2, r.height-2);
GC snapshotGC = new GC(display);
@@ -154,12 +153,17 @@ public class Snippet361 {
canvas = new Canvas() {
public void paint (Graphics g) {
if (image != null) {
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
+
/* Use Java2D here to modify the image as desired. */
Graphics2D g2d = (Graphics2D) g;
AffineTransform t = new AffineTransform();
t.translate(translateX, translateY);
t.rotate(rotate);
g2d.setTransform(t);
+ /*------------*/
+
g.drawImage(image, 0, 0, this);
}
}
@@ -167,7 +171,7 @@ public class Snippet361 {
frame.add(canvas);
composite.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
- e.result = "AWT Canvas showing Image";
+ e.result = "Image drawn in AWT Canvas";
}
});

Back to the top