Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Image with transparent background
Image with transparent background [message #448872] Fri, 14 January 2005 13:24
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Hi,

I call Button.setImage to set an own Image on a button. How can I get a
transparent background?

Bye Stefan


______________________________________________
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Test {
private static Display display;
private static Shell shell;
private static Image image;

public static void main(String[] args) {
display = new Display();
shell = new Shell(display);
shell.setLayout(new RowLayout());

image = getImage();
Button button = new Button(shell, SWT.PUSH);
button.setImage(image);

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}

private static Image getImage() {
Image image = new Image(null, 20, 20);

GC gc = new GC(image);
// gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BAC KGROUND));
// gc.fillRectangle(image.getBounds());
gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
gc.setLineWidth(3);
int[] points = new int[] {
7,2,
2,11,
11,4,
4,16,
13,8,
10,15,
15,12
};
gc.drawPolyline(points);
gc.dispose();

return image;
}
}
Previous Topic:IDocument modification
Next Topic:Setting source of SelectionEvent
Goto Forum:
  


Current Time: Wed Nov 13 22:49:13 GMT 2019

Powered by FUDForum. Page generated in 0.01749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top