- JavaFX 教程
- JavaFX - 首頁
- JavaFX - 概述
- JavaFX 安裝和架構
- JavaFX - 環境
- JavaFX - 使用 Netbeans 安裝
- JavaFX - 使用 Eclipse 安裝
- JavaFX - 使用 Visual Studio Code 安裝
- JavaFX - 架構
- JavaFX - 應用程式
- JavaFX 二維圖形
- JavaFX - 二維圖形
- JavaFX - 繪製直線
- JavaFX - 繪製矩形
- JavaFX - 繪製圓角矩形
- JavaFX - 繪製圓形
- JavaFX - 繪製橢圓
- JavaFX - 繪製多邊形
- JavaFX - 繪製折線
- JavaFX - 繪製三次貝塞爾曲線
- JavaFX - 繪製二次貝塞爾曲線
- JavaFX - 繪製弧形
- JavaFX - 繪製 SVG 路徑
- JavaFX 二維物件的屬性
- JavaFX - 描邊型別屬性
- JavaFX - 描邊寬度屬性
- JavaFX - 描邊填充屬性
- JavaFX - 描邊屬性
- JavaFX - 描邊連線屬性
- JavaFX - 描邊斜接限制屬性
- JavaFX - 描邊端點屬性
- JavaFX - 平滑屬性
- JavaFX 路徑物件
- JavaFX - 路徑物件
- JavaFX - LineTo 路徑物件
- JavaFX - HLineTo 路徑物件
- JavaFX - VLineTo 路徑物件
- JavaFX - QuadCurveTo 路徑物件
- JavaFX - CubicCurveTo 路徑物件
- JavaFX - ArcTo 路徑物件
- JavaFX 顏色和紋理
- JavaFX - 顏色
- JavaFX - 線性漸變圖案
- JavaFX - 徑向漸變圖案
- JavaFX 文字
- JavaFX - 文字
- JavaFX 效果
- JavaFX - 效果
- JavaFX - 顏色調整效果
- JavaFX - 顏色輸入效果
- JavaFX - 圖片輸入效果
- JavaFX - 混合效果
- JavaFX - 光暈效果
- JavaFX - 輝光效果
- JavaFX - 方框模糊效果
- JavaFX - 高斯模糊效果
- JavaFX - 運動模糊效果
- JavaFX - 反射效果
- JavaFX - 棕褐色效果
- JavaFX - 陰影效果
- JavaFX - 投影陰影效果
- JavaFX - 內陰影效果
- JavaFX - 照明效果
- JavaFX - Light.Distant 效果
- JavaFX - Light.Spot 效果
- JavaFX - Point.Spot 效果
- JavaFX - 位移貼圖
- JavaFX - 透視變換
- JavaFX 動畫
- JavaFX - 動畫
- JavaFX - 旋轉動畫
- JavaFX - 縮放動畫
- JavaFX - 平移動畫
- JavaFX - 淡入淡出動畫
- JavaFX - 填充動畫
- JavaFX - 描邊動畫
- JavaFX - 順序動畫
- JavaFX - 並行動畫
- JavaFX - 暫停動畫
- JavaFX - 路徑動畫
- JavaFX 圖片
- JavaFX - 圖片
- JavaFX 三維圖形
- JavaFX - 三維圖形
- JavaFX - 建立長方體
- JavaFX - 建立圓柱體
- JavaFX - 建立球體
- JavaFX 事件處理
- JavaFX - 事件處理
- JavaFX - 使用便捷方法
- JavaFX - 事件過濾器
- JavaFX - 事件處理器
- JavaFX UI 控制元件
- JavaFX - UI 控制元件
- JavaFX - 列表檢視
- JavaFX - 手風琴
- JavaFX - 按鈕欄
- JavaFX - 選擇框
- JavaFX - HTML 編輯器
- JavaFX - 選單欄
- JavaFX - 分頁
- JavaFX - 進度指示器
- JavaFX - 滾動窗格
- JavaFX - 分隔符
- JavaFX - 滑塊
- JavaFX - 微調器
- JavaFX - 分割窗格
- JavaFX - 表格檢視
- JavaFX - 選項卡窗格
- JavaFX - 工具欄
- JavaFX - 樹檢視
- JavaFX - 標籤
- JavaFX - 複選框
- JavaFX - 單選按鈕
- JavaFX - 文字欄位
- JavaFX - 密碼欄位
- JavaFX - 檔案選擇器
- JavaFX - 超連結
- JavaFX - 工具提示
- JavaFX - 警報
- JavaFX - 日期選擇器
- JavaFX - 文字區域
- JavaFX 圖表
- JavaFX - 圖表
- JavaFX - 建立餅圖
- JavaFX - 建立折線圖
- JavaFX - 建立面積圖
- JavaFX - 建立條形圖
- JavaFX - 建立氣泡圖
- JavaFX - 建立散點圖
- JavaFX - 建立堆疊面積圖
- JavaFX - 建立堆疊條形圖
- JavaFX 佈局面板
- JavaFX - 佈局面板
- JavaFX - HBox 佈局
- JavaFX - VBox 佈局
- JavaFX - BorderPane 佈局
- JavaFX - StackPane 佈局
- JavaFX - TextFlow 佈局
- JavaFX - AnchorPane 佈局
- JavaFX - TilePane 佈局
- JavaFX - GridPane 佈局
- JavaFX - FlowPane 佈局
- JavaFX CSS
- JavaFX - CSS
- JavaFX 多媒體
- JavaFX - 處理多媒體
- JavaFX - 播放影片
- JavaFX 有用資源
- JavaFX - 快速指南
- JavaFX - 有用資源
- JavaFX - 討論
JavaFX 幾何變換
淡入淡出動畫
下面是演示 JavaFX 中淡入淡出動畫的程式。將此程式碼儲存到名為 **FadeTransitionExample.java** 的檔案中。
import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class FadeTransitionExample extends Application {
@Override
public void start(Stage stage) {
//Drawing a Circle
Circle circle = new Circle();
//Setting the position of the circle
circle.setCenterX(300.0f);
circle.setCenterY(135.0f);
//Setting the radius of the circle
circle.setRadius(100.0f);
//Setting the color of the circle
circle.setFill(Color.BROWN);
//Setting the stroke width of the circle
circle.setStrokeWidth(20);
//Creating the fade Transition
FadeTransition fadeTransition = new FadeTransition(Duration.millis(1000));
//Setting the node for Transition
fadeTransition.setNode(circle);
//Setting the property fromValue of the transition (opacity)
fadeTransition.setFromValue(1.0);
//Setting the property toValue of the transition (opacity)
fadeTransition.setToValue(0.3);
//Setting the cycle count for the transition
fadeTransition.setCycleCount(50);
//Setting auto reverse value to false
fadeTransition.setAutoReverse(false);
//Playing the animation
fadeTransition.play();
//Creating a Group object
Group root = new Group(circle);
//Creating a scene object
Scene scene = new Scene(root, 600, 300);
//Setting title to the Stage
stage.setTitle("Fade transition example");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
使用以下命令在命令提示符下編譯並執行儲存的 java 檔案。
javac FadeTransitionExample.java java FadeTransitionExample
執行後,上述程式將生成如下所示的 JavaFX 視窗。
填充動畫
下面是演示 JavaFX 中填充動畫的程式。將此程式碼儲存到名為 **FillTransitionExample.java** 的檔案中。
import javafx.animation.FillTransition;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class FillTransitionExample extends Application {
@Override
public void start(Stage stage) {
//Drawing a Circle
Circle circle = new Circle();
//Setting the position of the circle
circle.setCenterX(300.0f);
circle.setCenterY(135.0f);
//Setting the radius of the circle
circle.setRadius(100.0f);
//Setting the color of the circle
circle.setFill(Color.BROWN);
//Setting the stroke width of the circle
circle.setStrokeWidth(20);
//Creating the fill Transition
FillTransition fillTransition = new FillTransition(Duration.millis(1000));
//Setting the shape for Transition
fillTransition.setShape(circle);
//Setting the from value of the transition (color)
fillTransition.setFromValue(Color.BLUEVIOLET);
//Setting the toValue of the transition (color)
fillTransition.setToValue(Color.CORAL);
//Setting the cycle count for the transition
fillTransition.setCycleCount(50);
//Setting auto reverse value to false
fillTransition.setAutoReverse(false);
//Playing the animation
fillTransition.play();
//Creating a Group object
Group root = new Group(circle);
//Creating a scene object
Scene scene = new Scene(root, 600, 300);
//Setting title to the Stage
stage.setTitle("Fill transition example");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
使用以下命令在命令提示符下編譯並執行儲存的 java 檔案。
javac FillTransitionExample.java java FillTransitionExample
執行後,上述程式將生成如下所示的 JavaFX 視窗。
描邊動畫
下面是演示 JavaFX 中描邊動畫的程式。將此程式碼儲存到名為 **StrokeTransitionExample.java** 的檔案中。
import javafx.animation.StrokeTransition;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class StrokeTransitionExample extends Application {
@Override
public void start(Stage stage) {
//Drawing a Circle
Circle circle = new Circle();
//Setting the position of the circle
circle.setCenterX(300.0f);
circle.setCenterY(135.0f);
//Setting the radius of the circle
circle.setRadius(100.0f);
//Setting the color of the circle
circle.setFill(Color.BROWN);
//Setting the stroke width of the circle
circle.setStrokeWidth(20);
//creating stroke transition
StrokeTransition strokeTransition = new StrokeTransition();
//Setting the duration of the transition
strokeTransition.setDuration(Duration.millis(1000));
//Setting the shape for the transition
strokeTransition.setShape(circle);
//Setting the fromValue property of the transition (color)
strokeTransition.setFromValue(Color.BLACK);
//Setting the toValue property of the transition (color)
strokeTransition.setToValue(Color.BROWN);
//Setting the cycle count for the transition
strokeTransition.setCycleCount(50);
//Setting auto reverse value to false
strokeTransition.setAutoReverse(false);
//Playing the animation
strokeTransition.play();
//Creating a Group object
Group root = new Group(circle);
//Creating a scene object
Scene scene = new Scene(root, 600, 300);
//Setting title to the Stage
stage.setTitle("Stroke transition example");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
使用以下命令在命令提示符下編譯並執行儲存的 java 檔案。
javac StrokeTransitionExample.java java StrokeTransitionExample
執行後,上述程式將生成如下所示的 JavaFX 視窗。
javafx_animations.htm
廣告