Displaying HTML in GWT Panel
Is there a way to display HTML in a GWT Pan开发者_StackOverflowel?
Short Answer: You can add HTML to a GWT Panel by creating an HTML widget and attaching that widget to your panel. For example...
HorizontalPanel hp = new HorizontalPanel();
HTML html = new HTML("<p>This is html with a <a href='www.google.com'>link</a></p>");
hp.add(html); // adds the widget to the panel
Long Answer: There are a variety of ways that you can add HTML to a GWT Panel. You should start by reading the Developer's Guide for GWT. Specifically, you should read the portions on Layout Using Panels and Widgets.
Also, the new declarative UI stuff in GWT 2.0 saves you from having to embed HTML into your Java.
<g:HTMLPanel>
Here <strong>is some HTML</strong>.
</g:HTMLPanel>
Ahhh. I was thinking about it differently. It's the widget I'm putting into the panel that needs to be formatted. Therefore if I do a
HTML example = new HTML(someText)
then add it to a panel it'll work :)
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
RootPanel.get().add(new HTML("<b>Gwt Html</b>"));
you can add this HTML widget to any panel with "panel.add(widget);
" code
精彩评论