Reputation: 34745
Is there a way to display HTML in a GWT Panel?
Upvotes: 3
Views: 19233
Reputation: 1601
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>
Upvotes: 5
Reputation: 993
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
Upvotes: 3
Reputation: 2285
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.
Upvotes: 11
Reputation: 34745
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 :)
Upvotes: 3