2 Replies Latest reply: Feb 28, 2013 3:35 AM by 967684 RSS

    Property animation

    967684
      Hi, i have pane and four button are his children. When i perform translate animation(i translate pane in down for 100 px) i can no longer click buttons.
      Please help.
        • 1. Re: Property animation
          James_D
          Can you post a simple executable example that demonstrates the problem? This works fine for me:
          import javafx.animation.TranslateTransition;
          import javafx.application.Application;
          import javafx.beans.value.ChangeListener;
          import javafx.beans.value.ObservableValue;
          import javafx.event.ActionEvent;
          import javafx.event.EventHandler;
          import javafx.geometry.Pos;
          import javafx.scene.Scene;
          import javafx.scene.control.Button;
          import javafx.scene.layout.Pane;
          import javafx.scene.layout.StackPane;
          import javafx.stage.Stage;
          import javafx.util.Duration;
          
          public class PaneTranslationTest extends Application {
          
            @Override
            public void start(Stage primaryStage) {
              final StackPane root = new StackPane();
              final Pane buttonContainer = new Pane();
              addButton(buttonContainer, "One", 10, 10);
              addButton(buttonContainer, "Two", 150, 10);
              addButton(buttonContainer, "Three", 10, 40);
              addButton(buttonContainer, "Four", 150, 40);
          
              StackPane.setAlignment(buttonContainer, Pos.TOP_CENTER);
              root.getChildren().add(buttonContainer);
              buttonContainer.setTranslateY(-100);
          
              final Button showControls = new Button("Show Controls");
              StackPane.setAlignment(showControls, Pos.BOTTOM_CENTER);
              showControls.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                  final TranslateTransition transition = new TranslateTransition(Duration.seconds(1), buttonContainer);
                  transition.setFromY(-100);
                  transition.setToY(0);
                  transition.play();
                }
              });
              root.getChildren().add(showControls);
          
              Scene scene = new Scene(root, 400, 400);
              primaryStage.setScene(scene);
              primaryStage.show();
            }
          
            private void addButton(final Pane pane, final String text, final double x,
                final double y) {
              final Button button = new Button(text);
              button.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                  System.out.println("Button " + text + " pressed");
                }
              });
              button.setLayoutX(x);
              button.setLayoutY(y);
              pane.getChildren().add(button);
            }
          
            public static void main(String[] args) {
              launch(args);
            }
          }
          • 2. Re: Property animation
            967684
            Thank you for your reply, i find the problem and it is totally different thing. So, i have
            Titled pane(which is closed) and pane, i was talking about, with 4 buttons, when i click
            on the titled pane it expands and pane moved down, what i didn't saw, because titled
            pane's pane is transparent, is that titled pane's pane is above pane with buttons and because of that
            they can't be clicked.
            Thank you and sorry for taking your time..