JavaFX简单入门(IDE 6.8 for JavaFX 1.2)

时间:2022-08-04 17:02:32

需要下载什么?哪个版本适合你?

This section guides you in determining what to download to get started using the JavaFX technology.
这一节告诉你开始使用JavaFX技术前要下载什么东西!

1. Ensure that you meet the system and software requirements. Check that you have the required hardware and available free disk space, and the correct version of the Java Software Development Kit (JDK) or Java Runtime Environment (JRE) prior to proceeding with any of the following installation instructions.
确信你已经达到了系统和软件的要求。检查需要的硬件和空闲的磁盘空间,正确的JDK版本和JRE版本。

2. For application developers:
对于应用开发人员

* If you are new to NetBeans IDE 6.5, download and install NetBeans IDE 6.8for JavaFX 1.2 (available for Microsoft Windows and Mac OS X platforms only).
如果你是NetBeans IDE 6.5的新用户,那么下载并安装 NetBeans IDE 6.8 for JavaFX 1.2

It is a full featured development environment that is bundled with the JavaFX Software Development Kit (SDK) and best practices samples to assist your software development project. The installation includes the Beta version of the JavaFX Mobile Emulator, which is currently available on the Microsoft Windows platform only.
他是一个全功能的和JavaFX软件开发工具绑定的开发环境。会给你最好的软件项目最佳体验的例子。安装包括了Beta版的移动设备模拟器,目前只有Windows平台可用。

* If you already have NetBeans IDE 6.5, update your IDE with JavaFX 1.0 Plugin for NetBeans (available for Microsoft Windows and Mac OS X platforms only).
如果你已经有了 NetBeans IDE 6.5, 那么升级你的 JavaFX 1.0 的IDE插件。

The plugins provide the features that support the development of JavaFX applications in the NetBeans IDE. They also include the JavaFX SDK and best practice samples. The installation includes the Beta version of the JavaFX Mobile Emulator, which is currently available on the Microsoft Windows platform only.
插件提供了NetBeans IDE开发 JavaFX需要的特性。也包括了JavaFX SDK和最佳体验的例子。包括了Beta版的移动设备模拟器,目前只有Windows平台可用。

* If you prefer command line development, download and install the JavaFX 1.0 SDK (available for Microsoft Windows and Mac OS X platforms only). The installation includes the Beta version of the JavaFX Mobile Emulator, which is currently available on the Microsoft Windows platform only.
如果你是命令行开发,下载并安装JavaFX 1.0 SDK.包括了Beta版的移动设备模拟器,目前只有Windows平台可用。

3. For web designers, download and install the JavaFX 1.0 Production Suite. (available for Microsoft Windows and Mac OS X platforms only)
对于 Web 设计人员,下载并安装 JavaFX 1.0 Production Suite

The JavaFX Production Suite is a set of tools for converting graphics to a format that can be used for JavaFX applications. Using the Production Suite plugins, you can export graphics from Adobe Illustrator or Adobe Photoshop into JavaFX format.
JavaFX Production Suite是一套将图片转化为JavaFX应用可以使用格式的工具集。使用这个插件,你可以从Adobe Illustrator 或者 Adobe Photoship 输出图形到JavaFX格式。



JavaFX入门-第一个程序的源代码和详细注释

Java代码 JavaFX简单入门(IDE 6.8 for JavaFX 1.2)
  1. /*
  2. * Main.fx
  3. *
  4. * Created on 2008-12-7, 6:50:06
  5. */  
  6.   
  7. package firstjavafxsphere;   
  8.   
  9. import javafx.scene.effect.DropShadow;   
  10. import javafx.scene.paint.Color;   
  11. import javafx.scene.paint.RadialGradient;   
  12. import javafx.scene.paint.Stop;   
  13. import javafx.scene.Scene;   
  14. import javafx.scene.shape.Circle;   
  15. import javafx.scene.text.Font;   
  16. import javafx.scene.text.Text;   
  17. import javafx.scene.text.TextAlignment;   
  18. import javafx.scene.transform.Scale;   
  19. import javafx.stage.Stage;   
  20. import javafx.animation.Timeline;   
  21. import javafx.animation.KeyFrame;   
  22. import javafx.animation.Interpolator;   
  23.   
  24. /**
  25. * @author java2000.net
  26. */  
  27. // 比例参数   
  28. var scale=1.0;   
  29. // 颜色,黄色   
  30. var color=Color.YELLOW;   
  31.   
  32. // 时间线   
  33. Timeline {   
  34.   // 重复次数,无限   
  35.    repeatCount: Timeline.INDEFINITE   
  36.   // 关键帧组   
  37.    keyFrames: [   
  38.     // 一个关键帧   
  39.      KeyFrame {   
  40.       // 此帧运行时间,2秒   
  41.        time: 2s   
  42.       // 在主时间线获得时,是否可以忽略此活动,默认为false   
  43.        canSkip: true  
  44.       // 此关键帧的参数和感兴趣的参数   
  45.        values: [   
  46.         // 比例变化到 0.0, 进入和离开都擦除   
  47.          scale => 0.0 tween Interpolator.EASEBOTH   
  48.         // 颜色变化到绿色   
  49.          color => Color.GREEN   
  50.        ]   
  51.      }   
  52.    ]   
  53. }.play(); // 运行时间线   
  54.   
  55. // 舞台/窗口   
  56. Stage {   
  57.   // 标题   
  58.    title: "My First JavaFX Sphere"  
  59.   // 窗口的宽度   
  60.    width: 250  
  61.   // 窗口的高度   
  62.    height: 250  
  63.   // 镜头   
  64.    scene: Scene {   
  65.     // 内容,节点列表   
  66.      content:[   
  67.       // 圆   
  68.        Circle {   
  69.         // 中心点的X/Y坐标   
  70.          centerX: 100  
  71.          centerY: 100  
  72.         // 圆的半径   
  73.          radius: 90  
  74.         // 填充设置,圆形梯度扩散填充   
  75.          fill:RadialGradient {   
  76.           // 圆心梯度的中心X和Y   
  77.           // 对于外部的100,100的圆,则75,75出现在外部圆的左上   
  78.            centerX:75  
  79.            centerY:75  
  80.           // 半径和外部的圆相同   
  81.            radius:90  
  82.           // 开始和结束值是否为比例值或者绝对值   
  83.           // 我们用绝对值   
  84.            proportional:false  
  85.           // 一些列沿半径的光圈数值,类似关键帧   
  86.            stops:[   
  87.             // 光圈1   
  88.              Stop {   
  89.               // 偏移在0,也就是起始点   
  90.                offset:0.0  
  91.               // 颜色为红色   
  92.                color:Color.RED   
  93.              },   
  94.             // 光圈2   
  95.              Stop{   
  96.               // 偏移在100%,颜色为深红   
  97.                offset:1.0  
  98.                color:Color.DARKRED   
  99.              }   
  100.            ]   
  101.          }   
  102.        }   
  103.       // 另一个内容,文本   
  104.        Text {   
  105.         // 文本的字体设置   
  106.          font: Font {   
  107.            size: 24  
  108.          }   
  109.         // 文字的坐标   
  110.          x: 20  
  111.          y: 90  
  112.         // 文字的对齐方式   
  113.          textAlignment:TextAlignment.CENTER   
  114.         // 文字的内容   
  115.          content: "Welcome to \nJavaFX World"  
  116.         // 文字的填充绑定到color变量   
  117.         // 时间线影响了color,则影响到了文字的颜色   
  118.          fill:bind color   
  119.         // 文字的阴影效果   
  120.          effect:DropShadow {   
  121.           // 阴影的偏移,在右下方   
  122.            offsetX:10  
  123.            offsetY:10  
  124.           // 阴影的颜色   
  125.            color:Color.color(0.1, 0.3, 0.1)   
  126.          }   
  127.         // 文字的变化   
  128.          transforms:Scale{   
  129.           // X不变   
  130.            x:1  
  131.           // Y绑定在scale变量   
  132.            y:bind scale   
  133.           // 变化的中心点,这个设置以文字的中心做变化   
  134.            pivotX:100  
  135.            pivotY:100  
  136.          }   
  137.        }   
  138.      ]   
  139.    }   
  140. }  
/* * Main.fx * * Created on 2008-12-7, 6:50:06 */package firstjavafxsphere;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;/** * @author java2000.net */// 比例参数var scale=1.0;// 颜色,黄色var color=Color.YELLOW;// 时间线Timeline { // 重复次数,无限 repeatCount: Timeline.INDEFINITE // 关键帧组 keyFrames: [ // 一个关键帧 KeyFrame { // 此帧运行时间,2秒 time: 2s // 在主时间线获得时,是否可以忽略此活动,默认为false canSkip: true // 此关键帧的参数和感兴趣的参数 values: [ // 比例变化到 0.0, 进入和离开都擦除 scale => 0.0 tween Interpolator.EASEBOTH // 颜色变化到绿色 color => Color.GREEN ] } ]}.play(); // 运行时间线// 舞台/窗口Stage { // 标题 title: "My First JavaFX Sphere" // 窗口的宽度 width: 250 // 窗口的高度 height: 250 // 镜头 scene: Scene { // 内容,节点列表 content:[ // 圆 Circle { // 中心点的X/Y坐标 centerX: 100 centerY: 100 // 圆的半径 radius: 90 // 填充设置,圆形梯度扩散填充 fill:RadialGradient { // 圆心梯度的中心X和Y // 对于外部的100,100的圆,则75,75出现在外部圆的左上 centerX:75 centerY:75 // 半径和外部的圆相同 radius:90 // 开始和结束值是否为比例值或者绝对值 // 我们用绝对值 proportional:false // 一些列沿半径的光圈数值,类似关键帧 stops:[ // 光圈1 Stop { // 偏移在0,也就是起始点 offset:0.0 // 颜色为红色 color:Color.RED }, // 光圈2 Stop{ // 偏移在100%,颜色为深红 offset:1.0 color:Color.DARKRED } ] } } // 另一个内容,文本 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 } } ] }}