Visual UI Designer

Hi All

I’m very sorry to ask this question as I suppose it must have been answered 10000000 times, buit I can’t find the answer, so…

I make a new CustomComponent with Eclipse editor and I want to “call it” from a button in the main class, but don’t know how to do it.
I simply want to call a form from the button and come back from it when the users validates.

@SuppressWarnings(“serial”)
public class Pruebas02Application extends Application {
public Window mainWindow;
public screenMain pantalla;
@Override
public void init() {
Label label = new Label(“Hello”);
mainWindow.addComponent(label);
pantalla = new screenMain(); // this is the CustomComponent
mainWindow.addComponent(pantalla); // do I have to do this ? or better in the button ?
Button boton = new Button(“Launch it”,this,“PruebaBoton”);
mainWindow.addComponent(boton);
setMainWindow(mainWindow);
}
public void PruebaBoton(ClickEvent event) {
!! I want to launch the component here !!

}		

}

Thank you for any help.
Loti.

Hi,

just call setMainWindow with your CustomComponent:


		PruebaBoton.addListener(new Button.ClickListener() {
			
			public void buttonClick(ClickEvent event) {
				mainWindow = new Window("myNewCustomComponent window title", new screenMain());
				setMainWindow(mainWindow);
			}
		});

Hi Oliver,

It doesn’t do anything.

No run time error, but the new window is not fired.

I Stepped with the debugger and the code is being executed.

The screenMain class is a button + a menu.

Thanks fro answering.

Please post your screenMain class.

Sorry Oliver I’ve been very busy and didn’t see your answer
this is the main class
[color=#002aff]
package com.example.pruebas02;

import java.util.Date;

import com.example.pruebas02.screenMain;
import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;

@SuppressWarnings(“serial”)
public class Pruebas02Application extends Application {
public Window mainWindow;
public Window pantalla;
@Override
public void init() {
mainWindow = new Window(“Pruebas02 Application”);
Label label = new Label(“Hello user”);
mainWindow.addComponent(label);
setMainWindow(mainWindow);
pantalla = new Window(“Prb”,new screenMain());
//mainWindow.addComponent(pantalla);
Button boton = new Button(“New Screen”,this,“PruebaBoton”);
mainWindow.addComponent(boton);
setMainWindow(mainWindow);
}
public void PruebaBoton(ClickEvent event) {
// TODO Auto-generated method stub
//mainWindow = new Window("myNewCustomComponent ", new screenMain());
//setMainWindow(mainWindow);
setMainWindow(pantalla);
}

}
[/color]

and here is the windows class I want to tun from the button

[color=#002aff]
package com.example.pruebas02;

import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.MenuBar;

@SuppressWarnings(“serial”)
public class screenMain extends CustomComponent {

@AutoGenerated
private AbsoluteLayout mainLayout;
@AutoGenerated
private MenuBar menuBar_1;
@AutoGenerated
private Button button_1;

/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */



/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */



/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */



/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.
 */
public screenMain() {
	buildMainLayout();
	setCompositionRoot(mainLayout);

	// TODO add user code here
}
public AbsoluteLayout handle(){
	return mainLayout;
}

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
	// common part: create layout
	mainLayout = new AbsoluteLayout();
	mainLayout.setImmediate(false);
	mainLayout.setWidth("100%");
	mainLayout.setHeight("100%");
	mainLayout.setMargin(false);
	
	// top-level component properties
	setWidth("100.0%");
	setHeight("100.0%");
	
	// button_1
	button_1 = new Button();
	button_1.setCaption("Button");
	button_1.setImmediate(true);
	button_1.setWidth("-1px");
	button_1.setHeight("-1px");
	mainLayout.addComponent(button_1, "top:74.0px;left:40.0px;");
	
	// menuBar_1
	menuBar_1 = new MenuBar();
	menuBar_1.setImmediate(false);
	menuBar_1.setWidth("240px");
	menuBar_1.setHeight("-1px");
	mainLayout.addComponent(menuBar_1, "top:0.0px;left:20.0px;");
	
	return mainLayout;
}

}
[/color]

My fault, it should be:

public void PruebaBoton(ClickEvent event) {
	// TODO Auto-generated method stub
	screenMain = new Window("myNewCustomComponent", new screenMain());
	screenMain.setWidth("500px");
	screenMain.setHeight("320px");
	mainWindow.addWindow(screenMain);
}

and not “setMainWindow”.

Ok, that’s working. Thank you.

It opens a modal window. I suppose there is a way to open a non movable and without title window ¿?.

Bye

You’re right.

modal window:

mainWindow.setModal(false);

non movable window:

mainWindow.setDraggable(false);

no title in window:

screenMain = new Window(null, new screenMain());