JavaFX Script With Eclipse 入门2

来源:岁月联盟 编辑:zhuzhu 时间:2008-07-20
现在,开始用Eclipse创建我们第一个JavaFX HelloWorld 程序。

  右击JavaFXapp > New > Other

image

  在New窗口中选择JavaFX > JavaFX File,

image

  点击Next,在File name输入:HelloWorld.fx,

image
点击Finish,HelloWorld.fx就被添加到JavaFXapp工程中,并且在右边自动被打开了。

image

  将下面代码粘贴到HelloWorld.fx中:

  import javafx.ui.*;
  Frame {
  title: "Hello World JavaFX"
  width: 200
  height: 50
  content: Label {
  text: "Hello World"
  }
  visible: true
  }

  运行我们的第一个JavaFX程序

  现在让我们用Eclipse运行我们的第一个JavaFX程序。

  在Eclipse主菜单,选择Run > Run...: