Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Renderer HTML in memory

import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class HTMLRendererInMemory {   public static void main(String[] args) {     String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>";     for (int i = 0; i < 100; i++){       html += "<a href=\"http://www.rntsoft.com\">rntsoft.com</a><br><br>";     }     html += "</BODY></HTML>";     Display display = new Display();     Shell shell = new Shell(display);     shell.setLayout(new FillLayout());     Browser browser = new Browser(shell, SWT.NONE);     browser.setText(html);     shell.open();     while (!shell.isDisposed()) {       if (!display.readAndDispatch())         display.sleep();     }     display.dispose();   } }