学习的第一天。。。
package com.example.demo1111;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class HelloApplication1 extends Application {
public static Stage stage;
@Override
public void start(Stage stage) {
//实现舞台跳转
HelloApplication1.stage=stage;//让舞台复制静态属性
stage.setTitle("登录|注册");//舞台名
VBox hBox=new VBox();
TextField user =new TextField();//输入
Button login=new Button("登录!");
Button regist=new Button("注册!");
regist.setOnAction(e->HelloApplication1.regist());//点击regist跳转
hBox.getChildren().addAll(login,regist);
Scene scene=new Scene(hBox,300,200);//创建场景
stage.setScene(scene);//场景放在舞台
stage.show();//展示舞台
}
public static void regist()
{//xin场景
VBox v=new VBox();
Label label=new Label("注册界面");
v.getChildren().add(label);
Scene scene=new Scene(v,500,500);
//设置新场景
HelloApplication1.stage.setScene(scene);
}
public static void main(String[] args) {
launch();
}
}