Transparent Background in Java SWT Label

Is there a Java SWT that I can place a label on top of another label and then have a label on top to have a transparent background?

I do this in a class that extends Composite, because I want to create a custom 2-label SWT button from "fancy". Thus, the label below will be a mask consisting only of an image, while the label will be a label with the text of the “fashion button”. But the label on top should have a transparent background so as not to cover the image underneath.

Currently, the label above closes the label below.

Any idea how I could do this?

Thank!

+5
source share
2 answers

Instead, you can try the following to get the same result.

  • "setText()", - .

. .

( ) /.

 Image image = new Image(display, "c:\\picture.jpeg"); 
 Shell shell = new Shell(SWT.NO_TRIM);
 shell.setBounds(10,10,200,200);
 shell.setBackgroundImage(image);
 shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
 Label label = new Label(shell, SWT.NONE);
 label.setText("LAbel text here. ");

. , "Button" api. , .

( )

Button button = new Button(shell, SWT.PUSH);
button.setImage(image);
button.setText("Click Me");

, , .

+1

drawString("text", x, y)

drawString("text", x, y, true)

,

+1

All Articles