sshahine / JFoenix

JavaFX Material Design Library
MIT License
6.29k stars 1.06k forks source link

JFXButton Animation Freeze #1077

Closed xizi110 closed 4 years ago

xizi110 commented 4 years ago

When the button is clicked to load the view, the button animation freezes。 example code:

public void start(Stage primaryStage) throws Exception {

        JFXButton load = new JFXButton("load");
        load.setPrefWidth(100);
        load.setPrefHeight(35);
        BorderPane borderPane = new BorderPane();
        borderPane.setLeft(load);

        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Main.fxml"));
        fxmlLoader.load();
        Node root = fxmlLoader.getRoot();

        // FXML has been loaded
        load.setOnAction(event -> {
            borderPane.setCenter(root);
        });

        Scene scene = new Scene(borderPane);
        primaryStage.setWidth(1200);
        primaryStage.setHeight(600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

like this fxml code:

<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="508.0" prefWidth="789.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <TableView prefHeight="508.0" prefWidth="339.0">
        <columns>
          <TableColumn prefWidth="75.0" text="C1" />
          <TableColumn prefWidth="75.0" text="C2" />
        </columns>
      </TableView>
      <Button mnemonicParsing="false" text="Button" />
      <Button mnemonicParsing="false" text="Button" />
      <CheckBox mnemonicParsing="false" text="CheckBox" />
      <ChoiceBox prefWidth="150.0" />
   </children>
</HBox>

There will be a short animation freeze。

jfoenixadmin commented 4 years ago

Rending tableview on the scene is still heavy in JavaFX and it's stalling the FX thread, thus freezing the ripple animation.