0
半透明の背景を持つキャンバスを作成したいと思います。だから私はこのような何か試してみました:半透明の背景を持つキャンバス
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Main {
public static int WIDTH=500;
public static int HEIGHT=70;
public static void main (String [] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(WIDTH,HEIGHT);
shell.setLayout(new GridLayout());
shell.setBackground(display.getSystemColor(SWT.COLOR_RED));
create(shell);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
private static void create(Shell shell){
Canvas c= new Canvas(shell, SWT.DOUBLE_BUFFERED);
GridData gd= new GridData();
gd.heightHint=HEIGHT-30;
gd.widthHint=WIDTH-30;
c.setLayoutData(gd);
c.setBackgroundMode(SWT.INHERIT_FORCE);
c.setBackground(new Color(shell.getDisplay(), 255, 255, 255, 100));
}
}
をしかし、私はキャンバスの背景に使用する色(100)のアルファ部分は、私は0を入れない限り、私ならば、SWTによって考慮していないようです0を使用すると、キャンバスは完全に透明になり、他のすべての場合は不透明になります。 私はここで間違いを犯しましたか、またはSWTの問題ですか?
グレッグ-449は、これがWindows環境のためにSWTのバグです指摘したように、私は、Windows 8
コードはMacOSでOK動作しますこれはWindowsの制限(Windowsではテストできません)の可能性があります。 –
また、最新のバージョンのSWTを使用しているかどうかを確認するには、色透過コードが新しく、新しいリリースで更新されている必要があります。 –
ありがとう、グレッグ、どのバージョンのSTWを使用していますか?私はバージョン4.629になっています – navy1978