View Full Version : Compare and set panel height

3 Feb 2010, 5:16 AM
I have a horizontal panel, which contains two vertical panels.

I want to compare the height of the two vertical panels and to set a new height value for the smaller panel. I try it this way:

// Create box "Prüfung"
final VerticalPanel boxPruefung = addBoxPruefung();

// Create box "Ansprechperson"
final VerticalPanel boxContactPerson = addBoxContactPerson();

int boxPruefungHeight = boxPruefung.getHeight();
int boxContactPersonHeight = boxContactPerson.getHeight();

if (boxPruefungHeight < boxContactPersonHeight) {
} else if (boxPruefungHeight > boxContactPersonHeight) {
I get following error:

java.lang.AssertionError: Method must be called after the component is rendered
I've tried to place the compare fragment at the end ot the method, but doesn't work. In my onModuleLoad() i just call some methods, so i'm not sure, where exactly to place this fragment.

3 Feb 2010, 7:57 AM
Try this:

protected void onRender(com.google.gwt.user.client.Element parent, int pos) {
super.onRender(parent, pos);

//put your fragment here


3 Feb 2010, 11:16 PM
i don't have not any onRender() method....i have the onModuleLoad(), which calls another five methods. Each this five methods have at the end something like:

RootPanel.get("widgetId").add(pruefPanel);so i don't need any onRender(). Is my approach wrong?

4 Feb 2010, 12:32 AM
java.lang.AssertionError: Method must be called after the component is rendered

Your piece of code must be called after the component is rendered... you have to make sure of that...

So, you need to override the onRender method in your parent container... and put the piece of code inside the onRender method....

Or you need to add a Events.Render listener to your parent container...

4 Feb 2010, 12:33 AM
okay, thanks....I'll try it.

10 Mar 2010, 1:30 AM
i made some changes in my project and now i have my widgets. The problem is, that i still can't get the hight of the box, but now there isn't any error message. I just get empty page im browser and that's all....here part of my code:

public class FachadministratorenWidget extends LayoutContainer {
private VerticalPanel boxPanel;
private Label title;
private VerticalPanel contentBox;
private HorizontalPanel titlePanel;
private List<String> adminList;

* Default constructor
public FachadministratorenWidget() {

// Initialize vars

// Style the ui elements


* Initialize vars
private void init() {

adminList = buildAdminFullName(getAdminFirstNames(), getAdminLastNames());

// Create the box
boxPanel = Utilities.createBox(503, 205);

System.out.println("\n\n\n" + boxPanel.getHeight());

// Create panel for the title
titlePanel = new HorizontalPanel();

// Create title
title = Utilities.setBoxTitle("Fachadministratoren");

// Create panel for the content
contentBox = new VerticalPanel();

for(int i=0; i < adminList.size(); i++) {
HorizontalPanel row = new HorizontalPanel();
row.setPixelSize(481, 31);
row.setStyleName("left-margin-double-spacer right-margin-double-spacer");

Label adminName = new Label(adminList.get(i));


if (i%2==1) {
row.setStyleName("selected-row-background left-margin-double-spacer");


* Style ui elemens.
private void style() {
// Set background for the title
title.setStyleName("label-size-491 box_title");

// Add title to panel

// Set size
// TODO Remove size if content added
contentBox.setSize(430, 150);

// Add title and content to the box

If i comment following row:

System.out.println("\n\n\n" + boxPanel.getHeight());

its working again.

My idea was to implement getter and setter for the hight in this widget, which i can use from the parent widget (with the "addListener(Events.Render...") . For that here must be possible to make something like


Is my approach corrent? Can someone help me to solve the problem?