I want to change media source and restart mediaplayer in javafx by using leap motion gesture.
how to decribe screentap gesture case in LeapListener for restart mediaplayer?
hot to change media source by using swipe gesture?
and is there anything to fix plz help (I'm beginner in java & this is the first time of programming)
here is my code
public class Leaptest extends Application{
private final LeapListener listener = new LeapListener();
private final Controller leapcontroller = new Controller();
private Media media = new Media("file:///C:/Users/halim.shin/workspace/Movie/flower.mp4");
private MediaPlayer player = new MediaPlayer(media);
private MediaView view = new MediaView(player);
#Override
public void start(Stage Stage) throws Exception {
leapcontroller.addListener(listener);
BorderPane root = new BorderPane();
int key_move_delta = 10;
double size_delta = 1.05;
root.setCenter(view);
Scene scene = new Scene(root,500,500,Color.BLACK);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
scene.setOnKeyPressed(new EventHandler<KeyEvent>(){
#Override
public void handle(KeyEvent event) {
// TODO Auto-generated method stub
switch(event.getCode()){
case UP : view.setTranslateY(view.getTranslateY() - key_move_delta); break;
case RIGHT : view.setTranslateX(view.getTranslateX() + key_move_delta); break;
case DOWN : view.setTranslateY(view.getTranslateY() + key_move_delta); break;
case LEFT : view.setTranslateX(view.getTranslateX() - key_move_delta); break;
case PAGE_UP : view.setScaleX(view.getScaleX()*size_delta); view.setScaleY(view.getScaleY()*size_delta); break;
case PAGE_DOWN : view.setScaleX(view.getScaleX()/size_delta); view.setScaleY(view.getScaleY()/size_delta); break;
case ENTER : player.pause(); break;
case SPACE : player.play(); break;
}
}
});
player.setCycleCount(MediaPlayer.INDEFINITE);
player.setMute(true);
// player.play(); //
Stage.setFullScreen(false);
Stage.setScene(scene);
Stage.show();
}
public void stop(){
leapcontroller.removeListener(listener);
}
public static void main(String[] args){
launch(args);
}
}
public class LeapListener extends Listener {
public void onConnect(Controller controller){
controller.enableGesture(Gesture.Type.TYPE_SWIPE);
controller.enableGesture(Gesture.Type.TYPE_CIRCLE);
controller.enableGesture(Gesture.Type.TYPE_SCREEN_TAP);
controller.enableGesture(Gesture.Type.TYPE_KEY_TAP);
}
public void onFrame(Controller controller){
Frame frame = controller.frame();
GestureList gestures = frame.gestures();
for(int i=0; i<gestures.count(); i++){
Gesture gesture = gestures.get(i);
**switch (gesture.type()){
case TYPE_SCREEN_TAP :
??????????????????
System.out.println("Key");
break;
default :
break;**
}
}
}
}
You have to communicate two different threads: the JavaFX thread and the Leap Motion one.
For that, you can easily add ObjectProperty<T> objects to the LeapListener class in order to set desired values at every frame for given gestures. Then you have to implement their related public ObservableValue<T> methods.
On the JavaFX thread, an anonimous ChangeListener<T> class can be added to listen for any change in the ObservableValue. Note you'll have to use Platform.runLater().
Starting with the LeapListener class:
public class LeapListener extends Listener {
private final BooleanProperty keyTap= new SimpleBooleanProperty(false);
public BooleanProperty keyTapProperty() { return keyTap; }
public enum DIRECTION { NONE,LEFT,RIGHT,UP,DOWN }
public ObjectProperty<DIRECTION> swipeGesture=new SimpleObjectProperty<>();
#Override
public void onConnect(Controller controller){
controller.enableGesture(Gesture.Type.TYPE_KEY_TAP);
controller.enableGesture(Gesture.Type.TYPE_SWIPE);
}
#Override
public void onFrame(Controller controller){
Frame frame = controller.frame();
// reset properties
keyTap.set(false);
swipeGesture.set(DIRECTION.NONE);
GestureList gestures = frame.gestures();
for(int i=0; i<gestures.count(); i++){
Gesture gesture = gestures.get(i);
switch (gesture.type()){
case TYPE_SCREEN_TAP :
keyTap.set(true);
break;
case TYPE_SWIPE:
SwipeGesture swipe = new SwipeGesture(gesture);
if(Math.abs(swipe.direction().getX()) >
Math.abs(swipe.direction().getY())){
if(swipe.direction().getX() > 0){
swipeGesture.set(DIRECTION.RIGHT);
} else {
swipeGesture.set(DIRECTION.LEFT);
}
} else {
if(swipe.direction().getY() > 0){
swipeGesture.set(DIRECTION.UP);
} else {
swipeGesture.set(DIRECTION.DOWN);
}
}
break;
default :
break;
}
}
}
}
While in your JavaFX class:
#Override
public void start(Stage stage) {
...
LeapListener leapListener=new LeapListener();
leapListener.keyTapProperty().addListener(
(ObservableValue<? extends Boolean> ov, Boolean t, final Boolean t1) -> {
if(t1){
Platform.runLater(() -> {
// React to Tap Gesture...
player.play();
});
}
});
leapListener.swipeGesture.addListener(
(ObservableValue<? extends LeapListener.DIRECTION> observable,
LeapListener.DIRECTION oldValue, LeapListener.DIRECTION newValue) -> {
Platform.runLater(()->{
// React to Swipe Gesture ...
switch(newValue){
case UP : break;
case RIGHT : break;
case DOWN : break;
case LEFT : break;
}
});
});
player.setCycleCount(MediaPlayer.INDEFINITE);
player.setMute(true);
// player.play(); //
stage.setFullScreen(false);
stage.setScene(scene);
stage.show();
}
Just note that whenever a Tap/Swipe gesture is detected by the Leap Motion controller, the properties are updated, and the listener is triggered. In the JavaFX thread now you can respond to that gestures.
Related
I'm using AndEngine to develop a simple test application. Everything is good, but the menu options does not show up. I don't know why I don't see the options menu button (the 3-dots touch button on bottom right). Help is much appreciated.
Here is the piece of code corresponding to the MenuScene:
public class MainActivity extends SimpleBaseGameActivity implements IOnMenuItemClickListener {
private static int CAMERA_WIDTH ;
private static int CAMERA_HEIGHT;
protected static final int MENU_ADD = 0;
protected static final int MENU_QUIT = MENU_ADD + 1;
private Font mFont,menuFont;
private MenuScene mMenuScene;
Camera camera;
Scene scene;
#Override
public EngineOptions onCreateEngineOptions() {
//default code
}
#Override
public void onCreateResources() throws IOException {
//some code
}
#Override
public Scene onCreateScene() {
//some code
}
#Override
public boolean onMenuItemClicked(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pMenuItemLocalX, final float pMenuItemLocalY) {
switch(pMenuItem.getID()) {
case MENU_ADD:
/* Restart the animation. */
Log.i("hello", "Menu ADD CLICKED");
return true;
case MENU_QUIT:
/* End Activity. */
this.finish();
return true;
default:
return false;
}
}
protected MenuScene createMenuScene() {
final MenuScene menuScene = new MenuScene(this.camera, new AlphaMenuSceneAnimator());
final IMenuItem resetMenuItem = new ColorMenuItemDecorator(new TextMenuItem(MENU_ADD, this.menuFont, "ADD ITEM", this.getVertexBufferObjectManager()), new Color(1,0,0), new Color(0,0,0));
menuScene.addMenuItem(resetMenuItem);
final IMenuItem quitMenuItem = new ColorMenuItemDecorator(new TextMenuItem(MENU_QUIT, this.menuFont, "QUIT", this.getVertexBufferObjectManager()), new Color(1,0,0), new Color(0,0,0));
menuScene.addMenuItem(quitMenuItem);
menuScene.buildAnimations();
menuScene.setBackgroundEnabled(false);
menuScene.setOnMenuItemClickListener(this);
return menuScene;
}
#Override
public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) {
if(pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) {
if(this.scene.hasChildScene()) {
/* Remove the menu and reset it. */
this.mMenuScene.back();
} else {
/* Attach the menu. */
this.scene.setChildScene(this.mMenuScene, false, true, true);
}
return true;
} else {
return super.onKeyDown(pKeyCode, pEvent);
}
}
}
I want drag an element in vbox as a parent and show node moving during drag and drop of element, how can do this with The slightest change.
Just register mouse listeners with the elements of the VBox. You want to call startFullDrag() on the node on a dragDetected event, and rotate the child nodes of the VBox on a dragReleased event. You can use the dragEntered and dragExited events if you want to give visual hints to the user about the drag.
See the API docs for more.
Simple example (code is way cleaner in JavaFX 8, btw):
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseDragEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
final VBox root = new VBox(5);
final ScrollPane scroller = new ScrollPane();
scroller.setContent(root);
final Scene scene = new Scene(scroller,400,200);
for (int i=1; i<=20; i++) {
final Label label = new Label("Item "+i);
addWithDragging(root, label);
}
// in case user drops node in blank space in root:
root.setOnMouseDragReleased(new EventHandler<MouseDragEvent>() {
#Override
public void handle(MouseDragEvent event) {
int indexOfDraggingNode = root.getChildren().indexOf(event.getGestureSource());
rotateNodes(root, indexOfDraggingNode, root.getChildren().size()-1);
}
});
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
private void addWithDragging(final VBox root, final Label label) {
label.setOnDragDetected(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
label.startFullDrag();
}
});
// next two handlers just an idea how to show the drop target visually:
label.setOnMouseDragEntered(new EventHandler<MouseDragEvent>() {
#Override
public void handle(MouseDragEvent event) {
label.setStyle("-fx-background-color: #ffffa0;");
}
});
label.setOnMouseDragExited(new EventHandler<MouseDragEvent>() {
#Override
public void handle(MouseDragEvent event) {
label.setStyle("");
}
});
label.setOnMouseDragReleased(new EventHandler<MouseDragEvent>() {
#Override
public void handle(MouseDragEvent event) {
label.setStyle("");
int indexOfDraggingNode = root.getChildren().indexOf(event.getGestureSource());
int indexOfDropTarget = root.getChildren().indexOf(label);
rotateNodes(root, indexOfDraggingNode, indexOfDropTarget);
event.consume();
}
});
root.getChildren().add(label);
}
private void rotateNodes(final VBox root, final int indexOfDraggingNode,
final int indexOfDropTarget) {
if (indexOfDraggingNode >= 0 && indexOfDropTarget >= 0) {
final Node node = root.getChildren().remove(indexOfDraggingNode);
root.getChildren().add(indexOfDropTarget, node);
}
}
public static void main(String[] args) {
launch(args);
}
}
This is an addendum to #James_D's excellent answer
This shows how to add an image preview to the draggable node as #James_D suggests in his comment:
private void addPreview(final VBox root, final Label label) {
ImageView imageView = new ImageView(label.snapshot(null, null));
imageView.setManaged(false);
imageView.setMouseTransparent(true);
root.getChildren().add(imageView);
root.setUserData(imageView);
root.setOnMouseDragged(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
imageView.relocate(event.getX(), event.getY());
}
});
}
private void removePreview(final VBox root) {
root.setOnMouseDragged(null);
root.getChildren().remove(root.getUserData());
root.setUserData(null);
}
Call addPreview() in label.setOnDragDetected(). Call removePreview() in label.setOnMouseDragReleased() and root.setOnMouseDragReleased().
There is a much better solution that is far cleaner now.
// Root is the node you want to drag, not the scene root.
root.setOnDragDetected(mouseEvent -> {
final ImageView preview = new ImageView(root.snapshot(null, null));
final Dragboard db = root.startDragAndDrop(TransferMode.ANY);
db.setContent( // Set your content to something here.
);
db.setDragView(preview.getImage());
mouseEvent.consume();
});
I'm trying to make a game, using slick2d, and lwjgl. I don't get why this code doesn't work
firstStage.java
package net.CharlesDickenson;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class firstStage extends BasicGameState {
public bossVar bossChecker() {
if(isBeforeMiddleBoss) return bossVar.beforeBoss;
if(isMiddleBoss) return bossVar.Middle;
if(isBeforeBoss) return bossVar.beforeBoss;
if(isBoss) return bossVar.Boss;
return null;
}
#SuppressWarnings("static-access")
public firstStage(int state) {
this.state = state;
}
#Override
public void init(GameContainer _arg0, StateBasedGame _arg1)
throws SlickException {
scoreBoard = new Image("res/scoreBoard.png");
backs = new Image("res/1stageBack.gif");
isBeforeMiddleBoss = true;
isMiddleBoss = false;
isBeforeBoss = false;
isBoss = false;
_arg0.setShowFPS(false);
}
#Override
public void render(GameContainer arg0, StateBasedGame _arg1, Graphics _g)
throws SlickException {
this._g = _g;
new Mob().getGraphics(_g);//i passed graphics
new Char().getGraphics(_g);//i passed graphics
new Bullet().getGraphics(_g);//i passed graphics
_g.drawImage(scoreBoard, 550, 5);
_g.drawImage(backs, 10, 10);
_g.drawString(fps, 580, 570);
_g.drawString("High Score-> Not avaiable", 560, 60);
_g.drawString("Score-> " + currScore, 595, 80);
}
#Override
public void update(GameContainer _arg0, StateBasedGame _arg1, int arg2)
throws SlickException {
fps = "Frame Per Second-> " + _arg0.getFPS();
bossVar b = bossChecker();
switch(b) {
case beforeMiddle :
break;
case Boss :
break;
default:
break;
}
}
#SuppressWarnings("static-access")
#Override
public int getID() {
return this.state;
}
private static int state;
private static int currScore = 0;
private static final int originX = 270;
private static final int originY = 490;
public static int X = originX;
public static int Y = originY;
private static String fps;
private Image scoreBoard;
private Image backs;
private Graphics _g;
public boolean isBeforeMiddleBoss;
public boolean isMiddleBoss;
public boolean isBeforeBoss;
public boolean isBoss;
}
Char.java
package net.CharlesDickenson;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
public class Char extends Bullet implements Entity {
#Override
public void getGraphics(Graphics _g) {
this._g = _g;//so i got graphics, but
if(!isInit) return;
_g.drawImage(Char, getCharX(), getCharY());//this codes doesn't works.
}
#Override
public int getCharX() {
switch(VarTracker.stage) {
case 1:
return firstStage.X;
}
return 0;
}
#Override
public int getCharY() {
switch(VarTracker.stage) {
case 1:
return firstStage.Y;
}
return 0;
}
public void setCharX(int i) {
System.out.println("asdgagsd");
switch(VarTracker.stage) {
case 1:
firstStage.X += i;
}
}
public void setCharY(int i) {
System.out.println("asdgagsd");
switch(VarTracker.stage) {
case 1:
firstStage.Y += i;
}
}
#Override
public void update() {
if(!isInit) return;
_g.drawImage(Char, getCharX(), getCharY());//this code doesn't work, too.
up = Keyboard.isKeyDown(Keyboard.KEY_UP);
down = Keyboard.isKeyDown(Keyboard.KEY_DOWN);
left = Keyboard.isKeyDown(Keyboard.KEY_LEFT);
right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT);
shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
z = Keyboard.isKeyDown(Keyboard.KEY_Z);
if(up && !shift) {
setCharY(6);
}
if(down && !shift) {
setCharY(-6);
}
if(left && !shift) {
setCharX(-6);
}
if(right && !shift) {
setCharX(6);
}
if(up && shift) {
setCharY(2);
}
if(down && shift) {
setCharY(-2);
}
if(left && shift) {
setCharX(-2);
}
if(right && shift) {
setCharX(2);
}
if(z) {
new Bullet().isFiring = true;
}
if(!z) {
new Bullet().isFiring = false;
}
}
#Override
public void init() {
System.out.println("<Char> Initializing...");
isInit = false;
try {
Char = new Image("res/char.png");
} catch (SlickException e) {
e.printStackTrace();
}
isInit = true;
System.out.println("<Char> Done with init()");
}
private boolean up;
private boolean down;
private boolean left;
private boolean right;
private boolean shift;
private boolean z;
private boolean isInit;
private Image Char;
private Graphics _g;
}
I passed graphics to other class using getGraphics method, to put a image, but it doesn't work.
at render method, it worked, but I can't put a image in other class.
The reason that it doesn't work is that you are using Graphics incorrectly. When Slick2d draws something, it uses the render method. This method is passed an instance of Graphics, to which you can draw stuff. When the call ends the Graphics object is no longer useful for anything. There is thus no reason to pass it to anything that doesn't use it immediately.
What you want to do is create a render method in your Mob, Char and Bullet classes. Make instances of said classes outside of the render method, for instance in init and store them in some data structure, for instance a List. In the render method, you simple traverse the list and call render or draw on each element. A quick example:
// Give the Entity interface two methods if they don't exist already:
public interface Entity {
void render(Graphics g);
void update(int delta);
}
// In firststage.java
List<Entity> list;
// In the init() method
public void init(GameContainer container, StateBasedGame game)
throws SlickException {
...
list = new ArrayList<Entity>();
list.add(new Mob());
list.add(new Char());
list.add(new Bullet());
}
// In the render method
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
...
for (Entity e : list) {
e.draw(g);
}
}
// In the update method
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {
...
for (Entity e : list) {
e.update(delta);
}
}
TL;DR version: The Graphics object exists only to be drawn to in a single render call.
Render is called many times a second, so object creation in that method is not recommended.
Object oriented programming is good at modeling objects. Games tend to model a lot of objects. Make use of it.
I'd like to make a draggable popup control, which is independent of its parent Window, and does not have the system's title bar.
I tried is to rewrite the JavaFx example for draggable panels in order to move an undecorated stage based on mouse events on a node, see code below. Unfortunately this doesn't seem to work properly, it's not smooth and jumps around the screen erratically for multiple screens. I read that some others used similar methods, however is this the only way to do this currently or did anyone find a nice solution ?
Thanks,
private Node makeDraggable(final Node node) {
final DragContext dragContext = new DragContext();
final Node wrapGroup = node;
wrapGroup.addEventFilter(
MouseEvent.MOUSE_PRESSED,
new EventHandler<MouseEvent>() {
public void handle(final MouseEvent mouseEvent) {
dragContext.mouseAnchorX = mouseEvent.getX();
dragContext.mouseAnchorY = mouseEvent.getY();
dragContext.initialTranslateX =
stage.getX();
dragContext.initialTranslateY =
stage.getY();
}
});
wrapGroup.addEventFilter(
MouseEvent.MOUSE_DRAGGED,
new EventHandler<MouseEvent>() {
public void handle(final MouseEvent mouseEvent) {
stage.setX(
dragContext.initialTranslateX
+ mouseEvent.getX()
- dragContext.mouseAnchorX);
stage.setY(
dragContext.initialTranslateY
+ mouseEvent.getY()
- dragContext.mouseAnchorY);
dragContext.initialTranslateX =
stage.getX();
dragContext.initialTranslateY =
stage.getY();
}
});
return node;
}
I used this sample method below when making a clock.
I've only tested it on one screen, because I don't have multiple screens available.
/** holder structure for drag delta amounts */
private static class Delta { double x, y; }
/** makes a stage draggable using a given node */
public static void makeDraggable(final Stage stage, final Node byNode) {
final Delta dragDelta = new Delta();
byNode.setOnMousePressed(new EventHandler<MouseEvent>() {
#Override public void handle(MouseEvent mouseEvent) {
// record a delta distance for the drag and drop operation.
dragDelta.x = stage.getX() - mouseEvent.getScreenX();
dragDelta.y = stage.getY() - mouseEvent.getScreenY();
byNode.setCursor(Cursor.MOVE);
}
});
byNode.setOnMouseReleased(new EventHandler<MouseEvent>() {
#Override public void handle(MouseEvent mouseEvent) {
byNode.setCursor(Cursor.HAND);
}
});
byNode.setOnMouseDragged(new EventHandler<MouseEvent>() {
#Override public void handle(MouseEvent mouseEvent) {
stage.setX(mouseEvent.getScreenX() + dragDelta.x);
stage.setY(mouseEvent.getScreenY() + dragDelta.y);
}
});
byNode.setOnMouseEntered(new EventHandler<MouseEvent>() {
#Override public void handle(MouseEvent mouseEvent) {
if (!mouseEvent.isPrimaryButtonDown()) {
byNode.setCursor(Cursor.HAND);
}
}
});
byNode.setOnMouseExited(new EventHandler<MouseEvent>() {
#Override public void handle(MouseEvent mouseEvent) {
if (!mouseEvent.isPrimaryButtonDown()) {
byNode.setCursor(Cursor.DEFAULT);
}
}
});
}
I have a GXT 2.x application with a Menubar Item that renders a separate LayoutContainer.
Here's the hierarchy
MainUI.java -> MenuBar.java -> ReservationPopUp.java
I have replaced my contents of ReservationPopUp.java with KNOWN working examples of LayoutContainer implementations and they respond to the ESC key and "X" button.
Here's how the MenuItem renders the ReservationPopUp.java
MenuItem mntmReserve = new MenuItem("Reserve");
mntmReserve.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
RootPanel.get().add(new ReservationPopUp());
}
Here's a slimmed down version of my ReservationPopUp.java
public class ReservationPopUp extends LayoutContainer {
public ReservationPopUp() {
}
#Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);
setSize("1024", "809");
final Window window = new Window();
window.setDraggable(false);
window.setSize(537, 399);
window.setPlain(true);
window.setModal(true);
window.setBlinkModal(true);
window.setHeading("Reserve A Server");
window.setClosable(true);
window.setOnEsc(true);
window.setSize("465", "345");
window.setLayout(new AbsoluteLayout());
LabelField lblfldUsers = new LabelField("Users");
window.add(lblfldUsers, new AbsoluteData(43, 218));
final ComboBox<AsyncUser> userList = new ComboBox<AsyncUser>();
window.add(userList, new AbsoluteData(81, 218));
userList.setEmptyText("Select a User...");
userList.setSize("347px", "24px");
LabelField labelServers = new LabelField("Servers");
window.add(labelServers, new AbsoluteData(32, 6));
final DualListField<AsyncServer> serverList = new DualListField<AsyncServer>();
....
window.add(serverList, new AbsoluteData(81, 6));
serverList.setSize("347px", "206px");
window.addButton(new Button("Cancel", new SelectionListener<ButtonEvent>() {
#Override
public void componentSelected(ButtonEvent ce) {
ReservationPopUp.this.hide();
}
}));
window.addButton(new Button("Reserve", new SelectionListener<ButtonEvent>() {
#Override
public void componentSelected(ButtonEvent ce) {
if (serverList.getToList().getListView().getItemCount() == 0 ) {
MessageBox.alert("Invalid Selection","No Server(s) Selected", null);
} else if ( userList.getValue() == null) {
} else {
// DO some stuff
ReservationPopUp.this.hide();
}
}
}));
window.addWindowListener(new WindowListener() {
#Override
public void windowHide(WindowEvent we) {
ReservationPopUp.this.hide();
}
});
window.setFocusWidget(window.getButtonBar().getItem(0));
add(window);
}
}
Window is a popup, it doesn't need to be (and shouldn't be) added to anything. Extend the Window class instead of the LayoutContainer, and instead of adding the ReservationPopup to the page, just call Window.show().