类继承Application,默认override start方法,创建,创建主函数,在主函数中调用Application.launch(args);默认调用顺序为init,start,stop方法默认只重写start方法。
下面是一段基本代码
package javafxlean;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class test extends Application{ //继承Application
public static void main(String[] args) {
Application.launch(args); //Application方法传参到javafx
}
@Override
public void start(Stage Stage) throws Exception { //自动生成override
Label hello = new Label("Hello JavaFx"); //创建标签
BorderPane bor = new BorderPane(hello); //创建布局pane
Scene scene = new Scene(bor,300,300); //创建场景
Stage.setScene(scene); //创建舞台
Stage.show();
Stage.setTitle("test");
}
}