Panel size problem

Hi,
first of all I would like to thanks all people that made and contribute to the growth of Vaadin…the framework it’s really amazing…:-))

I use Vaadin version 6.6.2 in a CRM project and until now, thanks to the very clear documentation (both the book and this forum), I was able to resolve almost all issues found. Now I have a problem with the sizing of a Panel, in particular by using this code:

[font=Courier New]

package com.example.vaadintest;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;

public class VaadintestApplication extends Application {
@Override
public void init() {
Window mainWindow = new Window(“Vaadintest Application”);
Button btnTest = new Button(“Press”);
btnTest.addListener(new Button.ClickListener() {

		@Override
		public void buttonClick(ClickEvent event) {
			
			Panel panel = new Panel("Example");
			panel.setSizeUndefined();
			
			HorizontalLayout hl = new HorizontalLayout();
			hl.setSizeUndefined();
			hl.setSpacing(true);
			VerticalLayout vlTF1 = new VerticalLayout();
			vlTF1.setSizeUndefined();
			final TextField tf1 = new TextField("Text1");
			tf1.setSizeUndefined();
			vlTF1.addComponent(tf1);
			hl.addComponent(vlTF1);
			
			final TextField tf2 = new TextField("Text2");
			tf2.setVisible(false);
			tf2.setSizeUndefined();
			VerticalLayout vlTF2 = new VerticalLayout();
			vlTF2.setSizeUndefined();
			vlTF2.addComponent(tf2);
			hl.addComponent(vlTF2);
			
			VerticalLayout vl = new VerticalLayout();
			vl.setSizeUndefined();
			vl.addComponent(hl);
			Button btn = new Button("Enable/disable");
			btn.addListener(new Button.ClickListener() {
				
				@Override
				public void buttonClick(ClickEvent event) {
					tf2.setVisible(!tf2.isVisible());
				}
			});
			vl.addComponent(btn);
			
			panel.setContent(vl);
			
			
			Window wnd = new Window("Test");
			wnd.setContent(panel);
			wnd.setModal(true);
			getMainWindow().addWindow(wnd);
			
		}
	});
	mainWindow.addComponent(btnTest);
	
	
	
	setMainWindow(mainWindow);
}

}

[/font]

If I press the first time the button “Enable/disable”, the text field tf2 will be shown and the panel and the corresponding modal window that contains the panel will grow correctly in the width. If I press the button a second time, the text field tf2 will be make invisible and panel and the modal window will not be resized correctly (just leave the old size like as the text field tf2 would be visible). Maybe I am wrong, but I think the right behaviour should be to resize the panel to a width that is enough to contains just the text field tf1. Is it right? What went wrong with the posted code?

Thanks for any tips…
Tiziano

Note: The intermediate layouts (vlTF1 and vlTF2) are for me necessary because the posted code is a simplification of a real code in CRM. In fact, the structure of the above code reflects the structure of the real code, so I would like to make this type of code working.

I tested your code and confirmed that there is a problem (only in Chrome though). I made a ticket about it (can be found
here
), lets hope our Dev team fixes it in the next release. Thank you for reporting the issue!

Thanks Thomas for your reply. Yes, effectivelly I forgot to mention that I tested the code only on Chrome 12…I hope too this issue will be resolved soon!