Java 类javafx.stage.Popup 实例源码

项目:xpanderfx    文件:GameOver.java   
/**
 * shows game-over pop-up.
 * @param controller 
 */
private void showGameOverPopup(MainFXMLDocumentController controller) {
    @SuppressWarnings("deprecation")
    BorderPane content =BorderPaneBuilder.create()
         .minWidth(230).minHeight(130)
         .bottom(getBottomBox(controller))
         .center(getCenterBox())
         .style(              "-fx-background-color:linear-gradient(darkslategrey, wheat, white);"
              + "-fx-background-radius:7;"
              + "-fx-border-radius:7")
         .build();
    pp = new Popup();
    pp.setAutoHide(true);
    pp.getContent().add(content);
    pp.show(controller.DOWN.getScene().getWindow());
}
项目:Incubator    文件:ProjectItemPresenter.java   
public void onMouseClickedShowItemMenuPopup(MouseEvent event) {
    LoggerFacade.INSTANCE.debug(this.getClass(), "On mouse clicked show ItemMenu popup"); // NOI18N

    if (!event.getButton().equals(MouseButton.SECONDARY)) {
        return;
    }

    final Popup popup = new Popup();
    popup.setAutoFix(true);
    popup.setAutoHide(true);
    popup.setHideOnEscape(true);

    final ItemMenuPopupView view = new ItemMenuPopupView();
    final ItemMenuPopupPresenter presenter = view.getRealPresenter();
    presenter.configure(popup, model);
    popup.getContent().add(view.getView());

    popup.show(parent, event.getScreenX(), event.getScreenY());
}
项目:Gargoyle    文件:GargoyleNotification.java   
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
        }
    });

    return timeline;
}
项目:myWMS    文件:BasicEntityEditor.java   
protected PopupWindow createPopup() {
    ListView<BODTO<T>> listView = new ListView<>();
    listView.getStyleClass().addAll("combo-box-popup");
    listView.setItems(completionItems);
    listView.cellFactoryProperty().bind(control.cellFactoryProperty());
    listView.setOnKeyReleased(e -> { 
        if (e.getCode() == KeyCode.ENTER ) { select(listView); e.consume(); }
        if (e.getCode() == KeyCode.ESCAPE ) { hidePopup(); e.consume(); }
    });

    listView.setOnMouseClicked(e -> { if (e.getClickCount() == 1) select(listView); e.consume();});

    Popup popup = new Popup();
    control.showPopup.bind(popup.showingProperty());
    popup.getContent().add(listView);
    textInput.updateValue("");
    return popup;
}
项目:yfiton    文件:Notifications.java   
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
            notification.onHideAction.handle(e);
        }
    });

    return timeline;
}
项目:grantmaster    文件:MainPageController.java   
@FXML
private void handleContextHelpButtonAction(ActionEvent event) {
 final Popup popup = new Popup();

  Tab activeTab = TabSelectionChangeListener.getActiveTab();
  if (activeTab == null || activeTab.getUserData() == null) {
    return;
  }
  // The help text is currently stored in userData.
  // TODO(gaborfeher): Find a better place.
  String helpText = (String) activeTab.getUserData();
  Label popupLabel = new Label(helpText);
  popupLabel.setStyle("-fx-border-color: black;");
  popup.setAutoHide(true);
  popup.setAutoFix(true);
  // Calculate popup placement coordinates.
  Node eventSource = (Node) event.getSource();
  Bounds sourceNodeBounds = eventSource.localToScreen(eventSource.getBoundsInLocal());
  popup.setX(sourceNodeBounds.getMinX() - 5.0);
  popup.setY(sourceNodeBounds.getMaxY() + 5.0);
  popup.getContent().addAll(popupLabel);
  popup.show(stage);
}
项目:examples-javafx-repos1    文件:ListViewHelperMainController.java   
@FXML
public void showEmployeesHelper(ActionEvent evt) {

    Button btn = (Button)evt.getSource();

    Point2D point = btn.localToScreen(0.0d + btn.getWidth(), 0.0d - btn.getHeight());

    try {

        Popup employeesHelper = new ListViewHelperEmployeesPopup(tfEmployee, point);

        employeesHelper.show(btn.getScene().getWindow());

    } catch(Exception exc) {
        exc.printStackTrace();
        Alert alert = new Alert(AlertType.ERROR, "Error creating employees popup; exiting");
        alert.showAndWait();
        btn.getScene().getWindow().hide();  // close and implicit exit
    }
}
项目:yfiton    文件:Notifications.java   
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
            notification.onHideAction.handle(e);
        }
    });

    return timeline;
}
项目:metastone    文件:CardPlayedToken.java   
public CardPlayedToken(GameBoardView boardView, Card card) {
    Window parent = boardView.getScene().getWindow();
    this.cardToken = new CardTooltip();

    popup = new Popup();
    popup.getContent().setAll(cardToken);
    popup.setX(parent.getX() + 40);
    popup.show(parent);
    popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

    cardToken.setCard(card);

    NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
    FadeTransition animation = new FadeTransition(Duration.seconds(1.2), cardToken);
    animation.setDelay(Duration.seconds(0.6f));
    animation.setOnFinished(this::onComplete);
    animation.setFromValue(1);
    animation.setToValue(0);
    animation.play();
}
项目:metastone    文件:CardRevealedToken.java   
public CardRevealedToken(GameBoardView boardView, Card card, double delay) {
    Window parent = boardView.getScene().getWindow();
    this.cardToken = new CardTooltip();

    popup = new Popup();
    popup.getContent().setAll(cardToken);
    popup.setX(parent.getX() + 40);
    popup.show(parent);
    popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

    cardToken.setCard(card);
    NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
    FadeTransition animation = new FadeTransition(Duration.seconds(delay), cardToken);
    animation.setOnFinished(this::secondTransition);
    animation.setFromValue(0);
    animation.setToValue(0);
    animation.play();
}
项目:UFMGame    文件:ViewPlayer.java   
/**
 * Method to load the viewplayer popup
 * @param inputPlayer player to be displayed in the popup
 * @throws IOException is thrown if the FXML file cannot be parsed.
 */
public static void start(Player inputPlayer) throws IOException {
    player = inputPlayer;
    if(player != null){
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Class.class
            .getResource("/data/gui/pages-game/ViewPlayer.fxml"));
        page = (AnchorPane) loader.load();
        FadeTransition ft = new FadeTransition(Duration.millis(900), page);
        ft.setFromValue(0.0);
        ft.setToValue(0.97);
        ft.play();
        popup = new Popup();
        popup.setAutoHide(true);
        popup.getContent().add(page);
        popup.show(Main.stage);
    }
}
项目:UFMGame    文件:SaveGameController.java   
/**
 * THe start method to load the Save game dialog
 * @throws IOException is thrown if the FXML file cannot be parsed.
 */
public static void start() throws IOException {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Class.class
            .getResource("/data/gui/pages-game/SaveGameDialog.fxml"));
    page = (AnchorPane) loader.load();
    FadeTransition ft = new FadeTransition(Duration.millis(900), page);
    ft.setFromValue(0.0);
    ft.setToValue(0.97);
    ft.play();
    page.setOpacity(0.85);
    popup = new Popup();
    popup.setAutoHide(true);
    popup.getContent().add(page);
    popup.show(Main.stage);
}
项目:UFMGame    文件:Popupscreen.java   
/**
 * Creates the popup screen and displays it
 */
public static void start(){
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Class.class
            .getResource("/data/gui/pages-game/Popup.fxml"));
    try {
        page = (AnchorPane) loader.load();
    } catch (IOException e) {
        e.printStackTrace();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(900), page);
    ft.setFromValue(0.0);
    ft.setToValue(0.97);
    ft.play();
    popup = new Popup();
    popup.setAutoHide(true);
    popup.getContent().add(page);
    popup.show(Main.stage);
}
项目:UFMGame    文件:OverwriteController.java   
/**
 * THe start method to load the are you sure to overwrite dialog
 * 
 * @param slot
 *            in where is game is saved
 * 
 * @throws IOException
 *             is thrown if the FXML file cannot be parsed.
 */
public static void start(int slot) throws IOException {
    saveslot = slot;
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Class.class
            .getResource("/data/gui/pages-game/OverwriteDialog.fxml"));
    page = (AnchorPane) loader.load();
    FadeTransition ft = new FadeTransition(Duration.millis(900), page);
    ft.setFromValue(0.0);
    ft.setToValue(0.97);
    ft.play();
    page.setOpacity(0.85);
    popup = new Popup();
    popup.setAutoHide(true);
    popup.getContent().add(page);
    popup.show(Main.stage);
}
项目:UFMGame    文件:ResultRoundDialogcontroller.java   
/**
 * Loads the result of a round dialog
 * @throws IOException is thrown if the FXML file cannot be parsed.
 */
public static void start() throws IOException{
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Class.class
            .getResource("/data/gui/pages-game/ResultRoundDialog.fxml"));
    page = (AnchorPane) loader.load();
    FadeTransition ft = new FadeTransition(Duration.millis(900), page);
    ft.setFromValue(0.0);
    ft.setToValue(0.97);
    ft.play();
    popup = new Popup();
    popup.setAutoHide(true);
    page.setOpacity(0.85);
    popup.getContent().add(page);
    popup.show(Main.stage);
    TeamBuilderController.start();
}
项目:UFMGame    文件:LoadGameController.java   
/**
 * THe start method to load the loadgame dialog
 * @throws IOException is thrown if the FXML file cannot be parsed.
 */
public static void start() throws IOException {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Class.class
            .getResource("/data/gui/pages-menu/LoadGameDialog.fxml"));
    page = (AnchorPane) loader.load();
    FadeTransition ft = new FadeTransition(Duration.millis(900), page);
    ft.setFromValue(0.0);
    ft.setToValue(0.97);
    ft.play();

    page.setOpacity(0.85);
    popup = new Popup();
    popup.setAutoHide(true);
    popup.getContent().add(page);
    popup.show(Main.stage);
}
项目:javafx-demos    文件:PopUpPositioningDemo.java   
public void showPopupWithinBounds(final Node node, final Popup popup) {
    final Window window = node.getScene().getWindow();
    double x = window.getX() + node.localToScene(0, 0).getX() + node.getScene().getX();
    double y = window.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + node.getBoundsInParent().getHeight();
    popup.show(window, x, y);
    if (!popup.getContent().isEmpty()) {
        final Node content = popup.getContent().get(0);
        x -= content.localToScene(0, 0).getX();
        y -= content.localToScene(0, 0).getY();
    }
    Point2D pd= new Point2D(x, y);

    double Z = window.getX();
    double gX = sp.getLayoutX();
    double c = sp.getWidth()-popup.getWidth();

    popup.show(window, (Z+gX+c+8), y);
}
项目:javafx-demos    文件:PopUpPositioningDemo.java   
public Point2D showPopUp(final Node node, final Popup popup){
        final Parent parent = node.getParent();
        final Bounds childBounds = node.getBoundsInParent();

        double x = 0;
        double y = 0;
        if (null != parent) {
            final Bounds parentBounds = parent.localToScene(parent.getBoundsInLocal());
            x = childBounds.getMinX() + parentBounds.getMinX() + parent.getScene().getX()
                    + parent.getScene().getWindow().getX();
            y = childBounds.getMaxY() + parentBounds.getMinY() + parent.getScene().getY()
                    + parent.getScene().getWindow().getY();
        }

        Point2D pd= new Point2D(x, y);
        popup.show(node, x, y);
        return pd;

}
项目:fx-experience    文件:FXRobotHandler.java   
@Override
public void sendToComponent(Object kb, final char ch, final boolean ctrl) {
  logger.trace("fire: {}", ch);

  final Window keyboardWindow = ((KeyboardPane) kb).getScene().getWindow();
  if (keyboardWindow != null) {
    final Scene scene;
    if (keyboardWindow instanceof Popup) {
      scene = ((Popup) keyboardWindow).getOwnerWindow().getScene();
    } else {
      scene = keyboardWindow.getScene();
    }

    Platform.runLater(() -> send(scene, ch, ctrl));
  }
}
项目:jointry    文件:FXRobotHandler.java   
@Override
public void sendToComponent(Object kb, final char ch, final boolean ctrl) {
    logger.trace("fire: {}", ch);

    final Window keyboardWindow = ((KeyboardPane) kb).getScene().getWindow();
    if (keyboardWindow != null) {
        final Scene scene;
        if (keyboardWindow instanceof Popup) {
            scene = ((Popup) keyboardWindow).getOwnerWindow().getScene();
        } else {
            scene = keyboardWindow.getScene();
        }

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                send(scene, ch, ctrl);
            }
        });
    }
}
项目:xpanderfx    文件:MainFXMLDocumentController.java   
/**
 * initialize the top side of the app
 */
private void topSideInit() {

    this.ICON.setGraphic(this.getImage("/resources/image/icon.png", 57));
    this.EXITER.setGraphic(this.getImage("/resources/image/exit.png", 57));
    this.MINIMISER.setGraphic(this.getImage("/resources/image/mini.png", 57));
    about = new Popup();
    help = new Popup();

}
项目:xpanderfx    文件:MainFXMLDocumentController.java   
/**
 * 
 * @param pp 
 */
private void popupCloser(Popup pp, Node node) {     
    ScaleTransition st = new ScaleTransition(Duration.seconds(.3), node);
    st.setToX(0);
    st.setToY(0);
    st.play();

    FadeTransition fd = new FadeTransition(Duration.seconds(.3), node);
    fd.setToValue(.2);
    fd.play();
    st.setOnFinished(e -> pp.hide());
}
项目:xpanderfx    文件:AboutFXMLDocumentController.java   
public void oakyButtonHandler(MouseEvent event, Popup pp) {
    ScaleTransition st = new ScaleTransition(Duration.seconds(.3), (Node) pp.getContent());
    st.setToX(0);
    st.play();

    FadeTransition fd = new FadeTransition(Duration.seconds(.3), (Node) pp.getContent());
    fd.setToValue(.2);
    st.setOnFinished(e -> pp.hide());
}
项目:Clipcon-Client    文件:ClipboardNotification.java   
protected void showPopup() {
    init();

    isShowing = true;

       VBox popupLayout = new VBox();
       popupLayout.setSpacing(10);
       popupLayout.setPadding(new Insets(10, 10, 10, 10));

       StackPane popupContent = new StackPane();
       popupContent.setPrefSize(width, height);
       popupContent.getStyleClass().add("notification");
       popupContent.getChildren().addAll(popupLayout);

       popup = new Popup();
       popup.setX(getX());
       popup.setY(getY());
       popup.getContent().add(popupContent);
       popup.addEventHandler(MouseEvent.MOUSE_PRESSED, new WeakEventHandler<>(event -> {
           fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.NOTIFICATION_PRESSED));
           hidePopUp();
       }));            
       popups.add(popup);

       // Add a timeline for popup fade out
       KeyValue fadeOutBegin = new KeyValue(popup.opacityProperty(), 1.0);            
       KeyValue fadeOutEnd   = new KeyValue(popup.opacityProperty(), 0.0);

       KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
       KeyFrame kfEnd   = new KeyFrame(popupAnimationTime, fadeOutEnd);

       timeline = new Timeline(kfBegin, kfEnd);
       timeline.setDelay(popupLifetime);
       timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
        hidePopUp();
       }));

       if (stage.isShowing()) {
           stage.toFront();
       } else {
           stage.show();
       }

       popup.show(stage);
       fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.SHOW_NOTIFICATION));
       timeline.play();
}
项目:Gargoyle    文件:GargoyleNotification.java   
private void addPopupToMap(Pos p, Popup popup) {
    List<Popup> popups;
    if (!popupsMap.containsKey(p)) {
        popups = new LinkedList<>();
        popupsMap.put(p, popups);
    } else {
        popups = popupsMap.get(p);
    }

    doAnimation(p, popup);

    // add the popup to the list so it is kept in memory and can be
    // accessed later on
    popups.add(popup);
}
项目:Gargoyle    文件:GargoyleNotification.java   
@Override
protected void interpolate(double frac) {
    Popup popup = popupWeakReference.get();
    if (popup != null) {
        double newAnchorY = oldAnchorY + distance * frac;
        popup.setAnchorY(newAnchorY);
    }
}
项目:yfiton    文件:Notifications.java   
private void addPopupToMap(Pos p, Popup popup) {
    List<Popup> popups;
    if (!popupsMap.containsKey(p)) {
        popups = new LinkedList<>();
        popupsMap.put(p, popups);
    } else {
        popups = popupsMap.get(p);
    }

    doAnimation(p, popup);

    // add the popup to the list so it is kept in memory and can be
    // accessed later on
    popups.add(popup);
}
项目:JavaFX_Game_Client    文件:WaitingRoomsManagerController.java   
/**
 * handle all popUp windows
 * 
 * @param text
 */
public void handlePopup(String text) {
    Platform.runLater(() -> {

        try {
            Popup popup = new Popup();

            Parent parent;

            parent = FXMLLoader.load(getClass().getResource("/Fxml/popup.fxml"));
            ImageView imageView = (ImageView) parent.lookup("#imgMessage");
            imageView.setImage(new Image(getClass().getResource("/Css/dialog-info.png").toString()));
            imageView.setOnMouseClicked(event -> popup.hide());
            Label lblMessage = (Label) parent.lookup("#lblMessage");
            lblMessage.setText(text);

            popup.setX(primaryStage.getX());
            popup.setY(primaryStage.getY());

            popup.getContent().add(parent);
            popup.setAutoHide(true);
            popup.show(primaryStage);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    });
}
项目:JavaFX_Game_Client    文件:LoginController.java   
/**
 * popUp windows
 * 
 * @param text
 */
public void handlePopup(String text) {
    Platform.runLater(() -> {

        try {
            Popup popup = new Popup();

            Parent parent;

            parent = FXMLLoader.load(getClass().getResource("/Fxml/popup.fxml"));
            ImageView imageView = (ImageView) parent.lookup("#imgMessage");
            imageView.setImage(new Image(getClass().getResource("/Css/dialog-info.png").toString()));
            imageView.setOnMouseClicked(event -> popup.hide());
            Label lblMessage = (Label) parent.lookup("#lblMessage");
            lblMessage.setText(text);

            // set the popup window position
            popup.setX(primaryStage.getX());
            popup.setY(primaryStage.getY());

            popup.getContent().add(parent);
            popup.setAutoHide(true);
            popup.show(primaryStage);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    });
}
项目:JavaFX_Game_Client    文件:GameRoomController.java   
/**
 * popUp windows
 * 
 * @param text
 */
public void handlePopup(String text) {
    Platform.runLater(() -> {

        try {
            Popup popup = new Popup();

            Parent parent;

            parent = FXMLLoader.load(getClass().getResource("/Fxml/popup.fxml"));
            ImageView imageView = (ImageView) parent.lookup("#imgMessage");
            imageView.setImage(new Image(getClass().getResource("/Css/dialog-info.png").toString()));
            imageView.setOnMouseClicked(event -> popup.hide());
            Label lblMessage = (Label) parent.lookup("#lblMessage");
            lblMessage.setText(text);

            popup.setX(primaryStage.getX());
            popup.setY(primaryStage.getY());

            popup.getContent().add(parent);
            popup.setAutoHide(true);
            popup.show(primaryStage);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    });
}
项目:optimal-spyglass-open-source    文件:TjfxFactory.java   
public Popup setupDialog(double width, double height, Node content) {
    Popup popup = new Popup();
    if (height != -1) {
        popup.setHeight(height);
    }
    if (width != -1) {
        popup.setWidth(width);
    }

    popup.getContent().add(content);

    return popup;
}
项目:jfx.radialmenu    文件:RadialDebug.java   
public RadialDebug(Popup popup, Params params) {
    this.popup = popup;
    this.params = params;

    Circle centerPoint = new Circle();
    setupCircle(centerPoint, params.getAnchorPoint().xProperty(), params.getAnchorPoint().yProperty(), 1.0d);
    decorateShape(centerPoint, null, Color.RED, 1);

    popup.getContent().add(centerPoint);

}
项目:yfiton    文件:Notifications.java   
private void addPopupToMap(Pos p, Popup popup) {
    List<Popup> popups;
    if (!popupsMap.containsKey(p)) {
        popups = new LinkedList<>();
        popupsMap.put(p, popups);
    } else {
        popups = popupsMap.get(p);
    }

    doAnimation(p, popup);

    // add the popup to the list so it is kept in memory and can be
    // accessed later on
    popups.add(popup);
}
项目:metastone    文件:JoustToken.java   
public JoustToken(GameBoardView boardView, Card card, boolean up, boolean won) {
    Window parent = boardView.getScene().getWindow();
    this.cardToken = new CardTooltip();

    popup = new Popup();
    popup.getContent().setAll(cardToken);
    popup.setX(parent.getX() + 600);
    popup.show(parent);
    int offsetY = up ? -200 : 100;
    popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5 + offsetY);

    cardToken.setCard(card);

    NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
    FadeTransition animation = new FadeTransition(Duration.seconds(1.0), cardToken);
    animation.setDelay(Duration.seconds(1f));
    animation.setOnFinished(this::onComplete);
    animation.setFromValue(1);
    animation.setToValue(0);
    animation.play();

    if (won) {
        ScaleTransition scaleAnimation = new ScaleTransition(Duration.seconds(0.5f), cardToken);
        scaleAnimation.setByX(0.1);
        scaleAnimation.setByY(0.1);
        scaleAnimation.setCycleCount(2);
        scaleAnimation.setAutoReverse(true);
        scaleAnimation.play();  
    }
}
项目:mongofx    文件:CodeAreaBuilder.java   
public CodeAreaBuilder setupAutocomplete(AutocompletionEngine service, String collectionName) {
  this.suggestContext = new SuggestContext(collectionName, codeArea);
  Popup popup = new Popup();
  popup.setAutoHide(true);
  popup.setHideOnEscape(true);

  ListView<Suggest> listView = createAutocompleteListView(popup);
  popup.getContent().add(listView);
  codeArea.setPopupWindow(popup);
  codeArea.setPopupAlignment(PopupAlignment.CARET_BOTTOM);
  codeArea.setPopupAnchorOffset(new Point2D(1, 1));

  Builder<KeyEvent> onKey =
      EventHandlerHelper.on(keyPressed(KeyCode.SPACE, KeyCombination.CONTROL_DOWN)).act(ae -> {
        if (popup.isShowing()) {
          popup.hide();
        }
        else {
          showPopup(service, popup, listView);
        }
      }) //
      .on(EventPattern.keyReleased(KeyCode.PERIOD)).act(ae -> showPopup(service, popup, listView));

  codeArea.textProperty().addListener(text -> {
    if (popup.isShowing()) {
      updateSuggestion(service, popup, listView);
    }
  });
  EventHandler<KeyEvent> onKeyHandler = onKey.create();
  EventHandlerHelper.install(codeArea.onKeyPressedProperty(), onKeyHandler);
  EventHandlerHelper.install(codeArea.onKeyReleasedProperty(), onKeyHandler);
  return this;
}
项目:mongofx    文件:CodeAreaBuilder.java   
private boolean updateSuggestion(AutocompletionEngine service, Popup popup, ListView<Suggest> listView) {
  List<Suggest> autocompleteList = buildAutocompleteFromPosition(service);
  if (!autocompleteList.isEmpty()) {
    listView.getItems().setAll(autocompleteList);
    listView.getSelectionModel().select(0);
    return true;
  }
  popup.hide();
  return false;
}
项目:mongofx    文件:CodeAreaBuilder.java   
private ListView<Suggest> createAutocompleteListView(Popup popup) {
  ListView<Suggest> listView = new SuggestListView();

  Builder<KeyEvent> popupKeyEvents =
      EventHandlerHelper.on(keyPressed(KeyCode.ESCAPE)).act(e -> popup.hide())//
      .on(keyPressed(KeyCode.ENTER)).act(e -> applySelected(popup, listView));
  EventHandlerHelper.install(listView.onKeyPressedProperty(), popupKeyEvents.create());

  listView.setOnMouseClicked(e -> {
    if (e.getClickCount() == 2) applySelected(popup, listView);
  });

  return listView;
}
项目:mongofx    文件:CodeAreaBuilder.java   
private void applySelected(Popup popup, ListView<Suggest> listView) {
  Suggest selectedItem = listView.getSelectionModel().getSelectedItem();
  if (selectedItem != null) {
    selectedItem.apply(suggestContext);
  }
  popup.hide();
}
项目:javafx-demos    文件:PopUpPositioningDemo.java   
private void showPopUp(StackPane sp3){
    Popup p = getPopUp();
    //p.show(sp3,0,0);
    showPopupWithinBounds(sp3, p);
    //Point2D pd =  showPopUp(sp3, p);
    //System.out.println(p.getWidth());

    //p.show(window, x, y);
}
项目:javafx-demos    文件:PopUpPositioningDemo.java   
public void showPopupBelowNode(final Node node, final Popup popup) {
    final Window window = node.getScene().getWindow();
    double x = window.getX() + node.localToScene(0, 0).getX() + node.getScene().getX();
    double y = window.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + node.getBoundsInParent().getHeight();
    popup.show(window, x, y);
    if (!popup.getContent().isEmpty()) {
        final Node content = popup.getContent().get(0);
        x -= content.localToScene(0, 0).getX();
        y -= content.localToScene(0, 0).getY();
    }
    Point2D pd= new Point2D(x, y);
    popup.show(window, x, y);
}