From 26a5b04e606c36b57d870a2b4b0f0eb71d7a0cd7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marko=20Gr=C3=B6nroos?= Date: Fri, 29 Aug 2008 10:46:59 +0000 Subject: [PATCH] Reformatted window opener example code. svn changeset:5300/svn branch:trunk --- .../toolkit/tests/book/WindowOpener.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/com/itmill/toolkit/tests/book/WindowOpener.java b/src/com/itmill/toolkit/tests/book/WindowOpener.java index b37d28108d..5e5f673fa7 100644 --- a/src/com/itmill/toolkit/tests/book/WindowOpener.java +++ b/src/com/itmill/toolkit/tests/book/WindowOpener.java @@ -12,22 +12,25 @@ import com.itmill.toolkit.ui.Window; 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); } @@ -35,6 +38,11 @@ public class WindowOpener extends CustomComponent implements 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); @@ -44,9 +52,6 @@ public class WindowOpener extends CustomComponent implements 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); -- 2.39.5