Roughian Examples Site Map - GWT Examples - Tutorials

HTMLPanel


Version 1.0 onwards

Add HTML to An HTMLPanel And You Can Work With The HTML



Notes


The HTMLPanel is a div-based widget that lets you add HTML elements and, if they have an ID, lets you add and remove widgets to these elements.

The HTMLPanel has it's uses. The alternative is to add the HTML directly to slots in the root panel, but if there's a chance of a duplicate ID, then you need to use the HTMLPanel.


Code


String html = "<div id='one' "
   + "style='border:3px dotted blue;'>"
   + "</div><div id='two' "
   + "style='border:3px dotted green;'"
   + "></div>";
HTMLPanel panel = new HTMLPanel(html);
panel.setSize("200px", "120px");
panel.addStyleName("demo-panel");
panel.add(new Button("Do Nothing"), "one");
panel.add(new TextBox(), "two");
RootPanel.get("demo").add(panel);