How to draw horizontal line (equivalent <HR> tag) in GWT 2.3 ?

5,041 views
Skip to first unread message

BM

unread,
Aug 16, 2011, 11:35:38 AM8/16/11
to Google Web Toolkit
I want to have equivalent <HR> HTML tag in resulting HTML using GWT.
Basically to draw a horizontal line.

How do I do that?

The one way I did using UIBinder was:

<g:HorizontalPanel styleName="{style.demo-hr}" height="0px"
width="100%">
</g:HorizontalPanel>

where:
<ui:style>
.demo-hr {
border: 1px solid #9A9A9A;
}
</ui:style>

Using firebug the resultant HTML is actually a table with 0px height
and not a <HR> tag. Is there any better way to achieve this?
Please advise.

Jens

unread,
Aug 16, 2011, 12:17:30 PM8/16/11
to google-we...@googlegroups.com
You can use <g:HTMLPanel> or <g:HTML> in your UiBinder xml and put the "<hr>" tag directly into it, e.g.:

<g:HTMLPanel>
  <h1>Title</h1>
  <g:FlowPanel ui:field="container"/>
  <hr style="width:100%;" />
  <g:FlowPanel ui:field="container"/>
</g:HTMLPanel>

-- J.

BM

unread,
Aug 16, 2011, 12:36:45 PM8/16/11
to Google Web Toolkit, bhushan. madan
You are awesome! Thank you very much!

cellepo

unread,
Jun 3, 2014, 2:32:50 PM6/3/14
to google-we...@googlegroups.com
I tried dominique calcinelli's suggestion but could not figure out how to get around this error:
 Node cannot be inserted at the specified point in the hierarchy

So I eneded up just making an <hr/> with HTML Widget instead, per this other related discussion:
https://groups.google.com/forum/#!topic/Google-Web-Toolkit/NMjozOU4UXk


On Friday, February 22, 2013 11:46:26 AM UTC-5, dominique calcinelli wrote:
First create the HTML <hr/> tag :

    InlineHTML hrTag = new InlineHTML().wrap(Document.get().createHRElement());

Then use it as follows :
  
        myPanel.add(hrTag);


ste...@spungin.tv

unread,
Dec 23, 2014, 8:15:32 AM12/23/14
to google-we...@googlegroups.com
This works for me:

panel.add(new HTML("<hr />"));

Reply all
Reply to author
Forward
0 new messages