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
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

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


Current Time: Thu Mar 28 16:55:39 GMT 2024

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

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

Back to the top