示例#1
0
 @Override
 protected void updateChildren() {
   super.updateChildren();
   if (buttonContainer != null) getChildren().add(0, buttonContainer);
   for (int i = 1; i < getChildren().size(); i++) getChildren().get(i).setMouseTransparent(true);
 }
示例#2
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    Circle cuser = new Circle(10, Color.DODGERBLUE);
    Circle cpass = new Circle(10, Color.DODGERBLUE);
    cuser.setOpacity(0);
    cpass.setOpacity(0);
    ButtonSkin users = new ButtonSkin(login);
    users.getChildren().add(0, cuser);
    login.setSkin(users);
    ButtonSkin passs = new ButtonSkin(hify);
    passs.getChildren().add(0, cpass);
    hify.setSkin(passs);
    login.setOnMousePressed(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            // .println("pressed");
            cuser.setOpacity(0.5);
            cuser.setRadius(10);
            cuser.setCenterX(event.getX());
            cuser.setCenterY(event.getY());
            Rectangle r = new Rectangle();
            r.setArcHeight(
                login.getBackground().getFills().get(0).getRadii().getTopLeftVerticalRadius());
            r.setArcWidth(
                login.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
            // .println(login.getPrefWidth()+"  "+login.getPrefHeight());
            r.setWidth(login.getPrefWidth());
            r.setHeight(login.getPrefHeight());
            cuser.setClip(r);
            Timeline tl = new Timeline();
            KeyValue kv =
                new KeyValue(
                    cuser.radiusProperty(), 1.5 * login.getPrefWidth(), Interpolator.EASE_OUT);
            KeyFrame kf = new KeyFrame(Duration.millis(1500), kv);
            tl.getKeyFrames().clear();
            tl.getKeyFrames().add(kf);
            tl.play();
            await.countDown();
          }
        });
    login.setOnMouseReleased(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            try {
              await.await();
            } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }

            awaitu.countDown();
            FadeTransition fd = new FadeTransition(Duration.millis(1500), cuser);
            fd.setFromValue(0.5);
            fd.setToValue(0);
            fd.setInterpolator(Interpolator.EASE_OUT);
            fd.play();
          }
        });
    hify.setOnMousePressed(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            // .println("pressed");
            cpass.setOpacity(0.5);
            cpass.setRadius(10);
            cpass.setCenterX(event.getX());
            cpass.setCenterY(event.getY());
            Rectangle r = new Rectangle();
            r.setArcHeight(
                hify.getBackground().getFills().get(0).getRadii().getTopLeftVerticalRadius());
            r.setArcWidth(
                hify.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
            r.setWidth(hify.getPrefWidth());
            r.setHeight(hify.getPrefHeight());
            cpass.setClip(r);
            Timeline tl = new Timeline();
            KeyValue kv =
                new KeyValue(
                    cpass.radiusProperty(), 1.5 * hify.getPrefWidth(), Interpolator.EASE_OUT);
            KeyFrame kf = new KeyFrame(Duration.millis(1500), kv);
            tl.getKeyFrames().clear();
            tl.getKeyFrames().add(kf);
            tl.play();
            awaitp.countDown();
          }
        });
    hify.setOnMouseReleased(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            try {
              awaitp.await();
            } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            awaitpa.countDown();
            FadeTransition fd = new FadeTransition(Duration.millis(1500), cpass);
            fd.setFromValue(0.5);
            fd.setToValue(0);
            fd.setInterpolator(Interpolator.EASE_OUT);
            fd.play();
          }
        });
    user.focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue) {
                  TranslateTransition fd = new TranslateTransition(Duration.millis(500), userlabel);
                  FadeTransition ff = new FadeTransition(Duration.millis(500), userlabel);
                  fd.setInterpolator(Interpolator.EASE_BOTH);
                  ff.setInterpolator(Interpolator.EASE_BOTH);
                  ff.setToValue(1.0);
                  ff.setFromValue(0.0);
                  fd.setByY(-3);
                  ParallelTransition pt = new ParallelTransition();
                  pt.getChildren().addAll(fd, ff);
                  pt.play();

                } else {
                  userlabel.setTranslateY(3);
                  userlabel.setOpacity(0);
                }
              }
            });
    pass.focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {

              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue) {
                  TranslateTransition fd = new TranslateTransition(Duration.millis(500), passlabel);
                  FadeTransition ff = new FadeTransition(Duration.millis(500), passlabel);
                  fd.setInterpolator(Interpolator.EASE_BOTH);
                  ff.setInterpolator(Interpolator.EASE_BOTH);
                  ff.setToValue(1.0);
                  ff.setFromValue(0.0);
                  fd.setByY(-3);
                  ParallelTransition pt = new ParallelTransition();
                  pt.getChildren().addAll(fd, ff);
                  pt.play();

                } else {
                  passlabel.setTranslateY(3);
                  passlabel.setOpacity(0);
                }
              }
            });
    p1.setEffect(new DropShadow());
  }