Roughian Examples Site Map - GWT Examples - Tutorials

CellPanel


Version 1.0 onwards

An Abstract Panel For Panels With Cells



Notes


Not something to play with when you are just getting started. It's not one of the basic layout widgets

Useful if you are passing a parameter or creating an abstract class where you don't know if it is going to be a HorizontalPanel, VerticalPanel, or a DockPanel

You can create your own cell panels using this, but it would have to be an exceptional situation.


Code

public void demo()
{
    MyPanel panel = new MyPanel();
    panel.setSize("200px", "130px");
    panel.addStyleName("demo-panel");
    Label label = new Label("Label");
    panel.add(label);
    label.setWidth("100px");
    label.setStyleName("demo-label");
    panel.setCellHeight(label, "100%");
    panel.setCellWidth(label, "100%");
    panel.setCellHorizontalAlignment(label,
        HasAlignment.ALIGN_CENTER);
    RootPanel.get("demo").add(panel);
}
class MyPanel extends CellPanel
{
    public void add(Widget child)
    {
        Element tr = DOM.createTR();
        Element td = DOM.createTD();
        DOM.appendChild(tr, td);
        DOM.appendChild(getBody(), tr);
        super.add(child, td);
    }
}