import com.itmill.toolkit.ui.Window.CloseEvent;
/** Component contains a button that allows opening a window. */
-public class WindowOpener extends CustomComponent implements
- Window.CloseListener {
- Window mainwindow; // Reference to main window
- Window mywindow; // The window to be opened
- Button openbutton; // Button for opening the window
+public class WindowOpener extends CustomComponent
+ implements Window.CloseListener {
+ Window mainwindow; // Reference to main window
+ Window mywindow; // The window to be opened
+ Button openbutton; // Button for opening the window
Button closebutton; // A button in the window
- Label explanation; // A descriptive text
+ Label explanation; // A descriptive text
public WindowOpener(String label, Window main) {
mainwindow = main;
/* The component consists of a button that opens the window. */
final OrderedLayout layout = new OrderedLayout();
- layout.addComponent(openbutton = new Button("Open Window", this,
- "openButtonClick"));
- layout.addComponent(explanation = new Label("Explanation"));
+
+ openbutton = new Button("Open Window", this, "openButtonClick");
+ explanation = new Label("Explanation");
+ layout.addComponent(openbutton);
+ layout.addComponent(explanation);
+
setCompositionRoot(layout);
}
public void openButtonClick(Button.ClickEvent event) {
/* Create a new window. */
mywindow = new Window("My Dialog");
+ mywindow.setPositionX(200);
+ mywindow.setPositionY(100);
+
+ /* Add the window inside the main window. */
+ mainwindow.addWindow(mywindow);
/* Listen for close events for the window. */
mywindow.addListener(this);
closebutton = new Button("Close", this, "closeButtonClick");
mywindow.addComponent(closebutton);
- /* Add the window inside the main window. */
- mainwindow.addWindow(mywindow);
-
/* Allow opening only one window at a time. */
openbutton.setEnabled(false);