1. 安装插件,e(fx)clipse
2. 新建JavaFX项目
3. 新建一个测试类,代码如下
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
Label label = new Label("Hello JavaFX");
GridPane gp = new GridPane();
gp.getChildren().add(label);
Scene scene = new Scene(gp, 300, 300);
primaryStage.setTitle("My First JavaFX");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
//启动JavaFX应用程序
launch(args);
//Application.launch(args);
}
}