Community
Participate
Working Groups
Browser.setText(String) does not work for me. Example to reproduce the bug: package com.fransson.test.swt.bug.browser; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; /** * <b>Bug in SWT 3.1</b><p/> * The method {@link org.eclipse.swt.browser.Browser#setText(String)} seems to be broken in SWT 3.1. * The <code>Browser</code> widget simply does not display the HTML source given to him. * The HTML source used in this example is not 100% correct, but it should display anyway - * just like with all browsers on the market. * It is used for brevity since a test with a correct HTML source produces the same problem. * <p/> * $Source: C:/data/cvs/repos/java/src/com/fransson/test/swt/bug/browser/BrowserBug.java,v $<br> * $RCSfile: BrowserBug.java,v $<br> * $Revision: 1.2 $<br> * $Date: 2005/08/11 17:01:29 $<br> * $Author: Jens $ * <p/> * <b>Creation Information</b> * <ul> * <li>Name: BrowserBug.java</li> * <li>User: Jens Fransson</li> * <li>Date: 11.08.2005</li> * <li>Time: 12:03:16</li> * </ul> * @author Jens Fransson */ public class BrowserBug { public static void main(final String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); System.out.println("--- SWT Library Information ---"); System.out.println("Platform: " + SWT.getPlatform()); System.out.println("Version : " + SWT.getVersion()); final RowLayout layout = new RowLayout(SWT.VERTICAL); layout.fill = true; shell.setLayout(layout); shell.setText("SWT Browser Bug"); final Button button = new Button(shell, SWT.PUSH); final Browser browser = new Browser(shell, SWT.NONE); button.setText("browser.setText()"); button.addSelectionListener(new SelectionListener(){ public void widgetDefaultSelected(final SelectionEvent e) { } public void widgetSelected(final SelectionEvent e) { shell.getDisplay().asyncExec(new Runnable() { public void run() { final String html = "<html><body><h1>Hello World!</h1>" + "This is a simple test.</body></html>"; final boolean ok = browser.setText(html); System.out.println("browser.setText(): " + ok); } }); } }); shell.setSize(320, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }
Running the program produces the output shown below. Although setText() returns true, there is no HTML rendered in the Browser. The HTML source obtained via right-click-->View Source shows only: "<HTML></HTML>". Output of the test program: --- SWT Library Information --- Platform: win32 Version : 3138 browser.setText(): true
Bizarre, your snippet works fine for me on win2000 and XP. The IE versions on them are 6.0.2800.1106 and 6.0.2800.1106.xpxp2.050301-1526, respectively. This problem happens consistently for you? And what is your IE version? And I assume for the eclipse version that you meant 3.1 right?
(In reply to comment #2) > Bizarre, your snippet works fine for me on win2000 and XP. The IE versions on > them are 6.0.2800.1106 and 6.0.2800.1106.xpxp2.050301-1526, respectively. > > This problem happens consistently for you? And what is your IE version? And I > assume for the eclipse version that you meant 3.1 right? Yes, it is the release version SWT 3.1. It is the standalone download of SWT only, as I do not use the Eclipse IDE. I suppose it must have to do with the IE version installed on my system. It is a German Windows XP with all latest software updates installed from Windows Update. The info dialog of the Internet Explorer shows: Version: 6.0.2900.2180.xpsp_sp2_gdr.050301-1519 The bug is always reproduceable.
A fix was added to 3.2.1 for this, see bug 141678. Marking report as a duplicate. *** This bug has been marked as a duplicate of bug 141678 ***