最小化面板按钮 [英] Minimize panel button

查看:300
本文介绍了最小化面板按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究这个简单面板的例子。

I'm working on this example of simple panel.

public class MainApp extends Application {

    private static BorderPane bp;

    @Override
    public void start(Stage stage) throws Exception {


        FlowPane flow = new FlowPane();
        flow.setPadding(new Insets(50, 5, 5, 5));
        flow.setVgap(15);
        flow.setHgap(15);
        flow.setAlignment(Pos.CENTER);

        HBox thb = new HBox();
        thb.setPadding(new Insets(13, 13, 13, 13));
        thb.setStyle("-fx-background-color: gray");

        DropShadow ds = new DropShadow();
        ds.setOffsetY(3.0);
        ds.setOffsetX(3.0);
        ds.setColor(Color.GRAY);

        bp = new BorderPane();
        bp.setEffect(ds);
        bp.setPrefSize(600, 500);
        bp.setMaxSize(600, 500);

        bp.setStyle("-fx-background-color:  white;");
        bp.setTop(thb);
        flow.getChildren().add(bp);
        Scene scene = new Scene(flow, 1200, 800);
        scene.getStylesheets().add("/styles/Styles.css");

        stage.setScene(scene);
        stage.show();
    }


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

}

你能帮我创建按钮吗?这使面板最小化。我想点击按钮缩小面板的大小。

Can you help me to create button which minimizes the panel. I want when I click the button to shrink the size of the panel.

推荐答案

我基本上不明白你想做什么。我认为这可能对你有帮助。

I don't understand basically what you trying to do. I think this might help you.

    final Button btnmin = new Button();
    flow.getChildren().add(btnmini)
    btnmin.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("mini.gif"))));

    btnmin.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
          Stage stage = (Stage)btnmin.getScene().getWindow();
          stage.setIconified(true);
        }
    });

这篇关于最小化面板按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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