[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Does browser rendering occur in the Display thread?

I'm fairly sure it does occure in the event dispatch thread.  It's fairly easy to check.  Try the following snippet:

[code]
public static void main(String[] args) {
    Display display = new Display();

    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());

    Browser b = new Browser(shell);
    b.setUrl("http://www.google.com";);

    GridData data = new GridData();
    data.horizontalAlignment = SWT.FILL;
    data.verticalAlignment = SWT.FILL;
    data.grabHorizontalSpace = true;
    data.grabVerticalSpace = true;
    b.setLayoutData(data);

    Button b = new Button(shell, SWT.PUSH);
    b.setText("Push Me!");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            while (true);
        }
    });

    shell.open();

    while (!shell.isDisposed())
        if (!display.readAndDispatch()) display.sleep();
}
[/code]

Sorry if anything in there is wrong, I just hacked that out from memory.  Anyway, push the button and then drag another window over the Shell.  If the Browser repaints even when the Button doesn't, then it's a safe bet that the rendering is done in a separate thread.  If the Browser doesn't repaint, then the rendering is really done in the event dispatch thread.