在学习javafx的过程中,不知道怎么出现一个弹窗,如,点击一个按钮出现一个修改信息的列表选项
终于在javafx文档示例中发现了类似的东西,记录一下,备忘
package demo9_button;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
//button一个----------------------------------
final Button b2 = new Button(" O K ");
b2.setOnAction(new EventHandler<ActionEvent>() {//鼠标点击
public void handle(ActionEvent e) {
Stage stage = new Stage();
Label l = new Label("显示出来了");
Scene s = new Scene(l,200,100);
stage.setScene(s);
stage.show();
}
});
StackPane root = new StackPane();
root.getChildren().add(b2);
Scene scene = new Scene(root, 500, 350);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}