I advise you subclass a FlowPanel.
Exemple (to head) :
class InputTextBox extends FlowPanel {
public InputTextBox(String labelText) {
super();
Label label = new Label(labelText);
TextBox input = new TextBox();
this.add(label);
this.add(input);
this.addStyleName("myBox");
}
}
It's give that:
<div class="myBox">
<div class="gwt-Label">Nom :</div>
<input type="text" tabindex="1" class="gwt-TextBox"/>
</div>
Exemple of css:
.myBox {
float: left; width: 200px;
}
.myBox .gwt-Label {
float: left;
width: 200px;
}
.myBox .gwt-TextBox {
float: left; width: 200px;
}
Maybe with GWT 2, Label class will generate a label node in the DOM ?
On 3 déc, 02:54, Open eSignForms <[email protected]> wrote:
> I have tried to create my own LabelTextBox by subclassing TextBox, but
> I'm not sure how to trick the widget so that when it's added, say to a
> VerticalPanel, it actually adds my own span element that contains the
> label element and the TextBox.getElement() (an InputElement) so that
> they all go together.
>
> I can create the span and put the elements inside, but when I add my
> widget, only the TextBox's InputElement is actually in the DOM, so
> clearly I'm not doing it right using:
>
> SpanElement spanElem;
> LabelElement labelElem;
> InputElement inputElem;
>
> public LabelTextBox(String labelText, boolean labelIsHtml, String
> className)
> {
> super(); // creates the TextBox
>
> inputElem = getElement().cast();
>
> spanElem = Document.get().createSpanElement();
> spanElem.setClassName(className);
>
> labelElem = Document.get().createLabelElement();
> if ( labelIsHtml )
> labelElem.setInnerHTML(labelText);
> else
> labelElem.setInnerText(labelText);
>
> String uid = DOM.createUniqueId();
> setId(uid);
>
> spanElem.appendChild(labelElem);
> spanElem.appendChild(inputElem);
> }
>
> public void setId(String id)
> {
> labelElem.setHtmlFor(id);
> inputElem.setId(id);
> }
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.