Hi,
my goal is to draw shapes (rectangles or what ever) directly on the screen. Therefore i create an transparent Shell and draw with the GC directly during the paintConrtrol invocation of a PaintListener. Problem is that everything which i draw has the same alpha value like the shell.
public class Recorder
{
private static final String WINDOW_TITLE = "overlay";
private final Display display = new Display();
private final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
public Recorder() throws AWTException
{
shell.setAlpha(100);
shell.setText(WINDOW_TITLE);
shell.setSize(new Point(500, 500));
FillLayout layout = new FillLayout();
layout.marginWidth = 5;
shell.addPaintListener(new PaintListener()
{
@Override
public void paintControl(PaintEvent e)
{
{
GC gc = e.gc;
gc.setBackground(new Color(e.display, 0, 0, 255));
gc.fillRectangle(20, 20, 40, 40);
gc.fillRectangle(100, 100, 40, 40);
}
}
});
shell.setRedraw(true);
}
public static void main(String[] args) throws AWTException
{
Recorder recorder = new Recorder();
recorder.shell.open();
//setWindowInputOnly(recorder.display, WINDOW_TITLE);
GC gc = new GC(recorder.display);
while (!recorder.shell.isDisposed())
{
if (!recorder.display.readAndDispatch())
recorder.display.sleep();
{
gc.setBackground(recorder.display.getSystemColor(SWT.COLOR_RED));
gc.fillRectangle(120, 120, 40, 40);
System.out.println("show rec");
}
}
recorder.display.dispose();
}
}
Does anyone know hot to draw intransparent stuff on an transparent shell?
Thanks in advance
Andreas
[Updated on: Sat, 16 April 2011 11:19]
Report message to a moderator