MiGLayout大小调整在JavaFX中无法正常工作 [英] MiGLayout sizing not working properly in JavaFX

查看:349
本文介绍了MiGLayout大小调整在JavaFX中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码段:

package javafxdemo;

import org.tbee.javafx.scene.layout.MigPane;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class FXDemo extends Application {

        @Override
        public void start (Stage stage) throws Exception {
                MigPane root = new MigPane();
                Scene scene = new Scene(root);

                Button b = new Button("Hello");
                root.getChildren().add(b);

                stage.setScene(scene);
                stage.setTitle("FX");
                stage.show();
        }

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

运行gui时显示不正确:框架尺寸小于按钮。为什么会这样?在设置场景的HBox布局中,它会自动调整大小,那么为什么使用MiGLayout它不起作用?

When running the gui doesn't show properly: the frame size is smaller than the button. Why does it happens? In HBox Layout when setting the scene it is automatically resized, so why with MiGLayout it doesn't work?

我正在使用MigLayout 4.3

I'm using MigLayout 4.3

推荐答案

因此,我提交了问题后来找到了解决方法:
只需在 stage.sizeToScene() > stage.show()。

So, I filed an issue and later found out a workaround for this: just add stage.sizeToScene() after stage.show().

这篇关于MiGLayout大小调整在JavaFX中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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