JavaFX 2.0中带有表格视图的弹出窗口 [英] Popup window with table view in JavaFX 2.0

查看:82
本文介绍了JavaFX 2.0中带有表格视图的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想单击一个按钮以使弹出窗口出现,其中带有tableview元素.谁能告诉我该怎么做?

I want to click a button in order to make a popup window appear with a tableview element inside it. Can anyone tell me how to do it?

谢谢.

推荐答案

这是JavaFX中简单弹出窗口的代码. 希望这会有所帮助.

This is the code for simple popup window in JavaFX. Hope this helps.

public class PopupExample extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(final Stage primaryStage) {
        primaryStage.setTitle("Popup Example");
        final Popup popup = new Popup();
        popup.setX(300);
        popup.setY(200);
        popup.getContent().addAll(new Circle(25, 25, 50, Color.AQUAMARINE));

        Button show = new Button("Show");
        show.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                popup.show(primaryStage);
            }
        });

        Button hide = new Button("Hide");
        hide.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                popup.hide();
            }
        });

        HBox layout = new HBox(10);
        layout.setStyle("-fx-background-color: cornsilk; -fx-padding: 10;");
        layout.getChildren().addAll(show, hide);
        primaryStage.setScene(new Scene(layout));
        primaryStage.show();
    }
}

这篇关于JavaFX 2.0中带有表格视图的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆