---
title: "javaFX学习例子"
author: "hbldw521"
date: "2009-01-22T17:34:16Z"
tags: []
categories: ["企业架构"]
slug: "javafx"
draft: false
lastmod: "2009-01-22T17:34:16Z"
id: 320037
url: "https://liudewen.iteye.com/blog/320037"
---

import javafx.scene.effect.DropShadow;
　　import javafx.scene.paint.Color;
　　import javafx.scene.paint.RadialGradient;
　　import javafx.scene.paint.Stop;
　　import javafx.scene.Scene;
　　import javafx.scene.shape.Circle;
　　import javafx.scene.text.Font;
　　import javafx.scene.text.Text;
　　import javafx.scene.text.TextAlignment;
　　import javafx.scene.transform.Scale;
　　import javafx.stage.Stage;
　　import javafx.animation.Timeline;
　　import javafx.animation.KeyFrame;
　　import javafx.animation.Interpolator;
　　// 比例参数
　　var scale=1.0;
　　// 颜色，黄色
　　var color=Color.YELLOW;
　　// 时间线
　　Timeline {
　　// 重复次数，无限
　　repeatCount: Timeline.INDEFINITE
　　// 关键帧组
　　keyFrames: 
　　}
　　]
　　}.play(); // 运行时间线
　　// 舞台/窗口
　　Stage {
　　// 标题
　　title: "My First JavaFX Sphere"
　　// 窗口的宽度
　　width: 250
　　// 窗口的高度
　　height: 250
　　// 镜头
　　scene: Scene {
　　// 内容，节点列表
　　content:
　　}
　　}
　　// 另一个内容，文本
　　Text {
　　// 文本的字体设置
　　font: Font {
　　size: 24
　　}
　　// 文字的坐标
　　x: 20
　　y: 90
　　// 文字的对齐方式
　　textAlignment:TextAlignment.CENTER
　　// 文字的内容
　　content: "Welcome to \nJavaFX World"
　　// 文字的填充绑定到color变量
　　// 时间线影响了color,则影响到了文字的颜色
　　fill:bind color
　　// 文字的阴影效果
　　effect:DropShadow {
　　// 阴影的偏移，在右下方
　　offsetX:10
　　offsetY:10
　　// 阴影的颜色
　　color:Color.color(0.1, 0.3, 0.1)
　　}
　　// 文字的变化
　　transforms:Scale{
　　// X不变
　　x:1
　　// Y绑定在scale变量
　　y:bind scale
　　// 变化的中心点，这个设置以文字的中心做变化
　　pivotX:100
　　pivotY:100
　　}
　　}
　　]
　　}
　　}