Java语言怎么编写可以不断闪烁并且变色的文字

Java语言怎么编写可以不断闪烁并且变色的文字?Java语言输出的问题太千篇一律的问题怎么解决?有什么编程的思路的呢?

以使用 Java 的 GUI 库来实现,比如 Swing 或 JavaFX
示例代码:

import javafx.animation.Animation;
import javafx.animation.FadeTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Duration;

public class BlinkingText extends Application {

    @Override
    public void start(Stage primaryStage) {
        Text text = new Text("Hello, World!");
        text.setFont(Font.font("Arial", 24));

        FadeTransition fadeIn = new FadeTransition(Duration.seconds(0.5), text);
        fadeIn.setFromValue(0.0);
        fadeIn.setToValue(1.0);
        fadeIn.setCycleCount(Animation.INDEFINITE);
        fadeIn.setAutoReverse(true);

        FadeTransition fadeOut = new FadeTransition(Duration.seconds(0.5), text);
        fadeOut.setFromValue(1.0);
        fadeOut.setToValue(0.0);
        fadeOut.setCycleCount(Animation.INDEFINITE);
        fadeOut.setAutoReverse(true);
        fadeOut.setDelay(Duration.seconds(0.5));

        fadeIn.play();
        fadeOut.play();

        StackPane root = new StackPane(text);
        root.setPrefSize(400, 300);
        Scene scene = new Scene(root);

        scene.setFill(Color.BLACK);

        primaryStage.setTitle("Blinking Text");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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


这个绝对详细:


希望被采纳

http://t.csdn.cn/gz87R

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^