Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Intransparent shape on an transparent shell(How to draw a shape on a transparent shell, made transparent with setAlpha)
Intransparent shape on an transparent shell [message #665815] Sat, 16 April 2011 11:19
Andreas   is currently offline Andreas Friend
Messages: 8
Registered: April 2011
Junior Member

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.setSize(new Point(500, 500));

        FillLayout layout = new FillLayout();
        layout.marginWidth = 5;

        shell.addPaintListener(new PaintListener()
            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);


    public static void main(String[] args) throws AWTException
        Recorder recorder = new Recorder();;

        //setWindowInputOnly(recorder.display, WINDOW_TITLE);

        GC gc = new GC(recorder.display);

        while (!
            if (!recorder.display.readAndDispatch())

                gc.fillRectangle(120, 120, 40, 40);
                System.out.println("show rec");



Does anyone know hot to draw intransparent stuff on an transparent shell?

Thanks in advance


[Updated on: Sat, 16 April 2011 11:19]

Report message to a moderator

Previous Topic:html5 placeholder like for SWT
Next Topic:Re: DirectoryDialog initial directory
Goto Forum:

Current Time: Fri Jan 22 00:50:02 GMT 2021

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

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

Back to the top