Package javafx.stage

Examples of javafx.stage.Popup


            final Text infoText = new Text(label.getText());
            infoText.setWrappingWidth(imgView.getImage().getWidth());
            info.setPrefHeight(imgView.getImage().getHeight() / 7);
            info.getChildren().add(infoText);
            frame.getChildren().addAll(imgView, info);
            final Popup popup = new Popup();
            popup.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                popup.hide();
              }
            });
            popup.setAutoHide(true);
            popup.getContent().add(frame);
            popup.setX(getScene().getWindow().getX() + getScene().getWindow().getWidth() / 2 - image.getWidth() / 2);
            popup.setY(getScene().getWindow().getY() + getScene().getWindow().getHeight() / 2 - image.getHeight() / 2);
            popup.show(getScene().getWindow());
          }
        });
        return zoomButton;
      }
      return null;
View Full Code Here


  private Popup popup;
  final DatePicker datePicker;
 
  public SimpleCalendar() {
    popup = new Popup();
    popup.setAutoHide(true);
    popup.setAutoFix(true);
    popup.setHideOnEscape(true);

    datePicker = new DatePicker();
View Full Code Here

   *            button will be added)
   * @return the {@linkplain Popup}
   */
  public static Popup alert(final double width, final double height,
      final String headerText, final KEY closeButtonKey, final Node... children) {
    final Popup alert = new Popup();
    alert.setAutoFix(true);
    alert.setAutoHide(false);
    alert.setHideOnEscape(false);
    if (headerText != null && !headerText.isEmpty()) {
      alert.getContent().add(new Label(headerText));
    }
    if (children != null && children.length > 0) {
      alert.getContent().addAll(children);
    } else {
      final KEY cbk = closeButtonKey != null ? closeButtonKey : KEY.CLOSE;
      final Button cb = ButtonBuilder.create().text(RS.rbLabel(cbk)).build();
      cb.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(final MouseEvent event) {
          alert.hide();
        }
      });
    }
    alert.sizeToScene();
    return alert;
  }
View Full Code Here

            }
        });
    }

    protected void createPopup() {
        popup = new Popup();
        popup.getContent().add(fxForm);
        popup.setAutoHide(true);
        popup.setHideOnEscape(true);
        popup.setAutoFix(true);
        popup.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
View Full Code Here

       
        stage.initStyle(StageStyle.TRANSPARENT);
        stage.setScene(scene);
        stage.show();
       
        Popup popup = new Popup();
        popup.getContent().add(root);
        popup.show(stage);

        //Place the window to an optimal position
        Utils.adjustLocation(popup);
    }
View Full Code Here

    {
      @Override
      public Void call(final Appointment appointment)
      {
        // create popup
        final Popup lPopup = new Popup();
        Button lButton = new Button("Close custom popup");
        lButton.setPrefWidth(lImageView.getImage().getWidth());
        lButton.setPrefHeight(lImageView.getImage().getHeight());
        lButton.setOnAction(new EventHandler<ActionEvent>()
        {
          @Override
          public void handle(ActionEvent evt)
          {
            lPopup.hide();
            appointment.setSummary("custom popup");
            lAgenda.refresh();
          }
        });
        lPopup.getContent().add(lButton);
        lPopup.show(lImageView, NodeUtil.screenX(lImageView), NodeUtil.screenY(lImageView));
        return null;
      }
    });
       
    // setup appointment groups
View Full Code Here

      lEditCallback.call(abstractAppointmentPane.appointment);
      return;
    }
   
    // create popup
    final Popup lPopup = new Popup();
    lPopup.setAutoFix(true);
    lPopup.setAutoHide(true);
    lPopup.setHideOnEscape(true);
    lPopup.setOnHidden(new EventHandler<WindowEvent>()
    {
      @Override
      public void handle(WindowEvent arg0)
      {
        setupAppointments();
      }
    });

    BorderPane lBorderPane = new BorderPane();
    lBorderPane.getStyleClass().add(getSkinnable().getClass().getSimpleName() + "Popup");
    lPopup.getContent().add(lBorderPane);

    // close icon
    {
      ImageViewButton lImageView = new ImageViewButton();
      lImageView.getStyleClass().add("close-icon");
      lImageView.setPickOnBounds(true);
      lImageView.setOnMouseClicked(new EventHandler<MouseEvent>()
      {
        @Override public void handle(MouseEvent evt)
        {
          lPopup.hide();
        }
      });
      lBorderPane.setRight(lImageView);
    }
   
    // initial layout
    VBox lMenuVBox = new VBox(padding);
    lBorderPane.setCenter(lMenuVBox);

    // time
    lMenuVBox.getChildren().add(new Text("Time:"));
    // start
    final CalendarTextField lStartCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
    lStartCalendarTextField.setLocale(getSkinnable().getLocale());
    lStartCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getStartTime());
    lMenuVBox.getChildren().add(lStartCalendarTextField);
    // end
    final CalendarTextField lEndCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
    lEndCalendarTextField.setLocale(getSkinnable().getLocale());
    lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
    lMenuVBox.getChildren().add(lEndCalendarTextField);
    lEndCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
    {
      @Override
      public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
      {
        abstractAppointmentPane.appointment.setEndTime(newValue);
        // refresh is done upon popup close
      }
    });
    lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
    // wholeday
    if ((abstractAppointmentPane.appointment.isWholeDay() != null && abstractAppointmentPane.appointment.isWholeDay() == true) || abstractAppointmentPane.appointment.getEndTime() != null)
    {
      final CheckBox lWholedayCheckBox = new CheckBox("Wholeday");
      lWholedayCheckBox.setId("wholeday-checkbox");
      lWholedayCheckBox.selectedProperty().set(abstractAppointmentPane.appointment.isWholeDay());
      lMenuVBox.getChildren().add(lWholedayCheckBox);
      lWholedayCheckBox.selectedProperty().addListener(new ChangeListener<Boolean>()
      {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue)
        {
          abstractAppointmentPane.appointment.setWholeDay(newValue);
          if (newValue == true)
          {
            abstractAppointmentPane.appointment.setEndTime(null);
          }
          else
          {
            Calendar lEndTime = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
            lEndTime.add(Calendar.MINUTE, 30);
            abstractAppointmentPane.appointment.setEndTime(lEndTime);
            lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
          }
          lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
          // refresh is done upon popup close
        }
      });
    }
    // event handling
    lStartCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
    {
      @Override
      public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
      {
        // enddate
        if (abstractAppointmentPane.appointment.isWholeDay())
        {
          abstractAppointmentPane.appointment.setStartTime(newValue);
        }
        else
        {
          // remember
          Calendar lOldStart = abstractAppointmentPane.appointment.getStartTime();

          // set
          abstractAppointmentPane.appointment.setStartTime(newValue);

          // end date
          if (abstractAppointmentPane.appointment.getEndTime() != null)
          {
            long lDurationInMS = abstractAppointmentPane.appointment.getEndTime().getTimeInMillis() - lOldStart.getTimeInMillis();
            Calendar lEndCalendar = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
            lEndCalendar.add(Calendar.MILLISECOND, (int)lDurationInMS);
            abstractAppointmentPane.appointment.setEndTime(lEndCalendar);

            // update field
            lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
          }

          // refresh is done upon popup close
        }
      }
    });

    // summary
    lMenuVBox.getChildren().add(new Text("Summary:"));
    TextField lSummaryTextField = new TextField();
    lSummaryTextField.setText(abstractAppointmentPane.appointment.getSummary());
    lSummaryTextField.textProperty().addListener(new ChangeListener<String>()
    {
      @Override
      public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
      {
        abstractAppointmentPane.appointment.setSummary(newValue);
        // refresh is done upon popup close
      }
    });
    lMenuVBox.getChildren().add(lSummaryTextField);

    // location
    lMenuVBox.getChildren().add(new Text("Location:"));
    TextField lLocationTextField = new TextField();
    lLocationTextField.setText( abstractAppointmentPane.appointment.getLocation() == null ? "" : abstractAppointmentPane.appointment.getLocation());
    lLocationTextField.textProperty().addListener(new ChangeListener<String>()
    {
      @Override
      public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
      {
        abstractAppointmentPane.appointment.setLocation(newValue);
        // refresh is done upon popup close
      }
    });
    lMenuVBox.getChildren().add(lLocationTextField);

    // actions
    lMenuVBox.getChildren().add(new Text("Actions:"))// TODO: internationalize
    HBox lHBox = new HBox();
    lMenuVBox.getChildren().add(lHBox);
    // delete
    {
      // close icon
      ImageViewButton lImageView = new ImageViewButton();
      lImageView.getStyleClass().add("delete-icon");
      lImageView.setPickOnBounds(true);
      lImageView.setOnMouseClicked(new EventHandler<MouseEvent>()
      {
        @Override public void handle(MouseEvent evt)
        {
          lPopup.hide();
          getSkinnable().appointments().remove(abstractAppointmentPane.appointment);
          // refresh is done via the collection events
        }
      });
      Tooltip.install(lImageView, new Tooltip("Delete")); // TODO: internationalize
      lHBox.getChildren().add(lImageView);
    }

    // construct a area of appointment groups
    lMenuVBox.getChildren().add(new Text("Group:"));
    GridPane lAppointmentGroupGridPane = new GridPane();
    lMenuVBox.getChildren().add(lAppointmentGroupGridPane);
    lAppointmentGroupGridPane.getStyleClass().add("AppointmentGroups");
    lAppointmentGroupGridPane.setHgap(2);
    lAppointmentGroupGridPane.setVgap(2);
    int lCnt = 0;
    for (Agenda.AppointmentGroup lAppointmentGroup : getSkinnable().appointmentGroups())
    {
      // create the appointment group
      final Pane lPane = new Pane();
      lPane.setPrefSize(15, 15);
      lPane.getStyleClass().addAll("AppointmentGroup", lAppointmentGroup.getStyleClass());
      lAppointmentGroupGridPane.add(lPane, lCnt % 10, lCnt / 10 );
      lCnt++;

      // tooltip
      if (lAppointmentGroup.getDescription() != null) {
        Tooltip.install(lPane, new Tooltip(lAppointmentGroup.getDescription()));
      }

      // mouse reactions
      lPane.setOnMouseEntered((mouseEvent) -> {
        if (!mouseEvent.isPrimaryButtonDown())
        {
          mouseEvent.consume();
          lPane.setCursor(Cursor.HAND);
        }
      });
      lPane.setOnMouseExited((mouseEvent) -> {
        if (!mouseEvent.isPrimaryButtonDown())
        {
          mouseEvent.consume();
          lPane.setCursor(Cursor.DEFAULT);
        }
      });
      final Agenda.AppointmentGroup lAppointmentGroupFinal = lAppointmentGroup;
      lPane.setOnMouseClicked((mouseEvent) -> {
        mouseEvent.consume();

        // assign appointment group
        abstractAppointmentPane.appointment.setAppointmentGroup(lAppointmentGroupFinal);

        // refresh is done upon popup close
        lPopup.hide();
      });
    }
   
    // show it just below the menu icon
    lPopup.show(abstractAppointmentPane, NodeUtil.screenX(abstractAppointmentPane), NodeUtil.screenY(abstractAppointmentPane.menuIcon) + abstractAppointmentPane.menuIcon.getHeight());
  }
View Full Code Here

  private void showPopup(MouseEvent evt)
  {
    // create popup
    if (popup == null)
    {
      popup = new Popup();
      popup.setAutoFix(true);
      popup.setAutoHide(true);
      popup.setHideOnEscape(true);
     
      // add the timepicker
View Full Code Here

//                      @Override public void dispose() { }
//                  });
//                  getScene().getRoot().impl_processCSS(true);
//              }
//          };
    Popup lPopup = new Popup();
    lPopup.setAutoFix(true);
    lPopup.setAutoHide(true);
    lPopup.setHideOnEscape(true);
    BorderPane lBorderPane = new BorderPane();
    lBorderPane.getStyleClass().add(this.getClass().getSimpleName() + "_popup");
    lBorderPane.setCenter(calendarPicker);
    calendarPicker.showTimeProperty().set( getSkinnable().getShowTime() );
   
    // because the Java 8 DateTime classes use the CalendarPicker, we need to add some specific CSS classes here to support seamless CSS
    if (getSkinnable().getStyleClass().contains(LocalDateTextField.class.getSimpleName())) {
      calendarPicker.getStyleClass().addAll(LocalDatePicker.class.getSimpleName());
    }
    if (getSkinnable().getStyleClass().contains(LocalDateTimeTextField.class.getSimpleName())) {
      calendarPicker.getStyleClass().addAll(LocalDateTimePicker.class.getSimpleName());
    }
   
    // add a close and accept button if we're showing time
    if ( getSkinnable().getShowTime())
    {
      VBox lVBox = new VBox();
      lBorderPane.rightProperty().set(lVBox);
     
      ImageView lAcceptIconImageView = new ImageViewButton();
      lAcceptIconImageView.getStyleClass().addAll("accept-icon");
      lAcceptIconImageView.setPickOnBounds(true);
      lAcceptIconImageView.setOnMouseClicked( (mouseEvent) ->  {
        getSkinnable().calendarProperty().set(calendarPicker.calendarProperty().get());
        lPopup.hide();
      });
      lVBox.add(lAcceptIconImageView);
     
      ImageView lCloseIconImageView = new ImageViewButton();
      lCloseIconImageView.getStyleClass().addAll("close-icon");
      lCloseIconImageView.setPickOnBounds(true);
      lCloseIconImageView.setOnMouseClicked( (mouseEvent) ->  {
        lPopup.hide();
      });
      lVBox.add(lCloseIconImageView);
    }
   
    // if a value is selected in date mode, immediately close the popup
    calendarPicker.calendarProperty().addListener( (observable) -> {
      if (lPopup != null &&  getSkinnable().getShowTime() == false && lPopup.isShowing()) {
        lPopup.hide();
      }
    });

    // when the popup is hidden
    lPopup.setOnHiding( (windowEvent) -> {
      // and time is not shown, the value must be set into the textfield
      if ( getSkinnable().getShowTime() == false) {
        getSkinnable().calendarProperty().set(calendarPicker.calendarProperty().get());
      }
      // but at least the textfield must be enabled again
      textField.setDisable(false);
    });
   
    // add to popup
    lPopup.getContent().add(lBorderPane);
   
    // show it just below the textfield
    textField.setDisable(true);
    lPopup.show(textField, NodeUtil.screenX(getSkinnable()), NodeUtil.screenY(getSkinnable()) + textField.getHeight());

    // move the focus over   
    calendarPicker.requestFocus(); // TODO: not working
  }
View Full Code Here

 
  protected Popup findPopup(Node ownedBy) {
    TestUtil.waitForPaintPulse();
    for (Window w : getWindows() ) {
      if (w instanceof Popup) {
        Popup lPopup = (Popup)w;
        if (ownedBy == null || ownedBy.equals(lPopup.getOwnerNode())) {
          return lPopup;
        }
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of javafx.stage.Popup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.