java - 如何翻译javaFX中的弹出窗口?

标签 java javafx javafx-2 javafx-8 scenebuilder

有什么方法可以在java FX中翻译诸如弹出窗口(不是Node)之类的东西吗? 例如淡入淡出过渡、平移过渡或任何时间线过渡...... 谢谢

最佳答案

创建一个属性并使用时间轴来“动画”该属性。使用该属性注册一个监听器,并在其值更改时更新窗口。

例如:

import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;

public class TranslateWindowExample extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button moveButton = new Button("Move");

        moveButton.setOnAction(event -> {
            double currentX = primaryStage.getX() ;
            DoubleProperty x = new SimpleDoubleProperty(currentX);
            x.addListener((obs, oldX, newX) -> primaryStage.setX(newX.doubleValue()));
            KeyFrame keyFrame = new KeyFrame(Duration.seconds(1), new KeyValue(x, currentX + 100));
            Timeline animation = new Timeline(keyFrame);
            animation.play();
        });

        StackPane root = new StackPane(moveButton);
        Scene scene = new Scene(root, 250, 150);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

关于java - 如何翻译javaFX中的弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25163923/

相关文章:

JavaFx - 以编程方式设置折线图系列颜色

java - HDFS 写入导致 "CreateSymbolicLink error (1314): A required privilege is not held by the client."

java - 如何在 slick2D java 游戏库中播放声音和音乐?

java - 如何检测 Java 中的方法调用?

java - 在 HTML 网页中嵌入 JavaFX 应用程序

java - : es2, sw 的图形设备初始化失败

java - 无法在 JavaFX JavaScript 中使用 URLClassLoader 加载自定义类

java - 如何更新WebView控件的flash插件

java - 如何使用 selenium 获取 HTML5 验证消息?

mysql - 警告消息不显示