gpt4 book ai didi

animation - 禁用 JavaFX 中的所有默认动画

转载 作者:行者123 更新时间:2023-12-05 05:14:35 25 4
gpt4 key购买 nike

我的应用程序中有一些幻影动画,但我不知道要删除它。您可以在下一个 GIF 上看到该动画。

enter image description here

图表和轴的动画被禁用。左边部分的结构是:

<TitledPane>
<content>
<AnchorPane>
<LinearChart/>
<Canvas/>
</AnchorPane>
</content>
</TitledPane>

任何想法,为什么会这样?我可以只删除那个动画吗?可能存在禁用所有默认动画的方法吗?

最佳答案

我创建了一个示例应用程序来演示您要实现的行为。在这个应用程序中,我设置了 Min Width左边的TitlePane's AnchorPane300 .

Main

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author blj0011
*/
public class JavaFXApplication259 extends Application
{

@Override
public void start(Stage stage) throws Exception
{
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

Scene scene = new Scene(root);

stage.setScene(scene);
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
launch(args);
}

}

Controller

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.XYChart;

/**
*
* @author blj0011
*/
public class FXMLDocumentController implements Initializable
{

@FXML
LineChart chart1, chart2;

@Override
public void initialize(URL url, ResourceBundle rb)
{
// TODO
XYChart.Series<Number, Number> series1 = new XYChart.Series<>();
series1.setName("Series 1");
series1.getData().add(new XYChart.Data<>(1000, 20));
series1.getData().add(new XYChart.Data<>(2000, 100));
series1.getData().add(new XYChart.Data<>(3000, 80));
series1.getData().add(new XYChart.Data<>(4000, 180));
series1.getData().add(new XYChart.Data<>(5000, 10000));
series1.getData().add(new XYChart.Data<>(6000, -10));
chart1.getData().add(series1);
}

}

FXML

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.chart.LineChart?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane id="AnchorPane" prefHeight="581.0" prefWidth="908.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication259.FXMLDocumentController">
<children>
<SplitPane dividerPositions="0.29797979797979796" layoutX="6.0" layoutY="7.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TitledPane animated="false" layoutX="-11.0" layoutY="74.0" text="untitled" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane minHeight="0.0" minWidth="300.0">
<children>
<LineChart fx:id="chart1" layoutX="-117.0" layoutY="-43.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<xAxis>
<NumberAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</AnchorPane>
</content>
</TitledPane>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TitledPane animated="false" layoutX="127.0" layoutY="170.0" minWidth="300.0" text="untitled" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<LineChart fx:id="chart2" layoutX="91.0" layoutY="65.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<xAxis>
<NumberAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</AnchorPane>
</content>
</TitledPane>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>

关于animation - 禁用 JavaFX 中的所有默认动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52308488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com