Ich habe folgende GUI erzeugt:
das ganze sieht so aus
nun hab ich in photoshop nen testbild als jpg gemacht, das ich auf diese schwarze fläche legen will gemacht.
im code hab ich die stelle markiert. Aber das funktioniert irgendwie nicht.[/img]
Code:
final Display display = new Display();
//Shell must be created with style SWT.NO_TRIM
final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
shell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
//define a region
Region region = new Region();
/* TestGUI Hintergrund
region.add(circle(80, 0, 80));
region.add(circle(80, 100, 80));
region.add(new Rectangle(20, 20, 250, 200));
region.subtract(circle(20, 67, 50));
region.subtract(new int[]{67, 50, 55, 105, 79, 105});
region.subtract(circle(60, 67, 150));
*/
/*
region.add(circle(150, 170, 150));
region.add(new Rectangle(170, 0, 600, 450));
region.add(circle(100, 170, 380));
region.add(circle(120, 120, 430));
*/
//Anfang ist oben links die Ecke
region.add(new int[]{238, 0, 785, 0, 800, 15, 800, 455, 785 ,470
, 785, 526, 765, 545, 290, 545, 270, 525
, 270, 510, 185, 495, 146, 513, 90, 416
, 118, 389, 241, 6});
region.add(circle(222, 233, 225));
region.add(circle(75, 77, 485));
region.add(circle(75, 236, 460));
region.add(circle(15, 785, 15));//rechts Oben, runde Ecke
region.add(circle(15, 785, 455));
region.add(circle(15, 770, 530));
/*
region.subtract(new int[]{80, 50, 55, 105, 79, 105});
region.subtract(circle(60, 100, 150));
*/
//define the shape of the shell using setRegion
shell.setRegion(region);
Rectangle size = region.getBounds();
shell.setSize(size.width, size.height);
//shell.setSize(800,600);
/***************************************************************
Hier ist der versuch, das bild reinzusetzen!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Label label = new Label(shell, SWT.IMAGE_JPEG);
ImageData data = new ImageData("title.jpg");
Image i = new Image(display, data);
label.setImage(i);
***************************************************************/
//add ability to move shell around
Listener l = new Listener() {
Point origin;
public void handleEvent(Event e) {
switch (e.type) {
case SWT.MouseDown:
origin = new Point(e.x, e.y);
break;
case SWT.MouseUp:
origin = null;
break;
case SWT.MouseMove:
if (origin != null) {
Point p = display.map(shell, null, e.x, e.y);
shell.setLocation(p.x - origin.x, p.y - origin.y);
}
break;
}
}
};
shell.addListener(SWT.MouseDown, l);
shell.addListener(SWT.MouseUp, l);
shell.addListener(SWT.MouseMove, l);
//add ability to close shell
Button b = new Button(shell, SWT.PUSH);
b.setBackground(shell.getBackground());
b.setText("X");
b.pack();
b.setLocation(150, 250);
b.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event e)
{
shell.close();
}
}
);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
region.dispose();
display.dispose();
}
das ganze sieht so aus
nun hab ich in photoshop nen testbild als jpg gemacht, das ich auf diese schwarze fläche legen will gemacht.
im code hab ich die stelle markiert. Aber das funktioniert irgendwie nicht.[/img]