com.google.gwt.user.client.ui.FieldSet Maven / Gradle / Ivy
The newest version!
package com.google.gwt.user.client.ui;
import com.google.gwt.dom.client.Node;
import com.google.gwt.user.client.DOM;
/**
* This class emulates an FieldSet in html.
* @author mnouwens
*
*/
public class FieldSet extends ComplexPanel implements InsertPanel.ForIsWidget {
/**
* Creates an empty flow panel.
*/
public FieldSet() {
setElement(DOM.createFieldSet());
}
/**
* Adds a new child widget to the panel.
*
* @param w
* the widget to be added
*/
@Override
public void add(Widget w) {
add(w, getElement());
}
public void setFor(String forField) {
getElement().setAttribute("for", forField);
}
@Override
public void clear() {
try {
doLogicalClear();
} finally {
// Remove all existing child nodes.
Node child = getElement().getFirstChild();
while (child != null) {
getElement().removeChild(child);
child = getElement().getFirstChild();
}
}
}
@Override
public void insert(IsWidget w, int beforeIndex) {
insert(asWidgetOrNull(w), beforeIndex);
}
/**
* Inserts a widget before the specified index.
*
* @param w
* the widget to be inserted
* @param beforeIndex
* the index before which it will be inserted
* @throws IndexOutOfBoundsException
* if beforeIndex
is out of range
*/
@Override
public void insert(Widget w, int beforeIndex) {
insert(w, getElement(), beforeIndex, true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy