[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: Browser does not display text or content

Got it...I cut out too many lines that the Shell needs to have a GridLayout set!

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.browser.*;

public class MySnippet128
{
    public static void main(String [] args)
    {
        Display display = new Display();
        final Shell shell = new Shell(display, SWT.TOOL);
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginHeight = -1;
        gridLayout.marginHeight = -1;
        gridLayout.numColumns = 1;
        shell.setLayout(gridLayout);

GridData data = new GridData();
final Browser browser = new Browser(shell, SWT.TOOL);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
data.horizontalSpan = 1;
browser.setLayoutData(data);


shell.open();
browser.setText("<html><body style=\"overflow:auto;\" text=\"#000000\" bgcolor=\"#ffffe1\"><font size=2><b>TEST</b></font></body></html>");
// browser.setUrl("http://eclipse.org";);


        while (!shell.isDisposed())
       	{
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}

AL wrote:

Hi,

I have a very simple program below that opens a browser. The browser opens but Browser.setText(...) or Browser.setUrl(...) does not show the content. Just an emptry screen...Please advise...I have been trying to figure this one out too long :-( This example was taken from one of the snippets (Snippet128) and simplified down.

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;

public class MySnippet128 {
    public static void main(String [] args) {
        Display display = new Display();
        final Shell shell = new Shell(display, SWT.TOOL);

shell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

shell.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));

        Composite composite= new Composite(shell, SWT.NONE);
        GridLayout layout= new GridLayout(1, false);
        layout.marginHeight= 0;
        layout.marginWidth= 0;
        composite.setLayout(layout);
        GridData gd= new GridData(GridData.FILL_BOTH);
        composite.setLayoutData(gd);

        // The browser.  Does not matter if 'composite'
        // or 'shell' is used to create a browser.
        // Same result: Blank screen
        Browser browser= new Browser(composite, SWT.MULTI | SWT.READ_ONLY);

        // Make sure the browser content occupies the composite's area
        gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
        browser.setLayoutData(gd);

        // Open the shell.
        shell.open();

// Nothing gets displayed!
browser.setText("<html><body style=\"overflow:auto;\" text=\"#000000\" bgcolor=\"#ffffe1\"><font size=2><b>TEST</b></font></body></html>");


        // Same if I set url! Nothing gets displayed
        // browser.setUrl("www.eclipse.org");

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}