【问题标题】:MiGLayout sizing not working properly in JavaFXMiGLayout 大小在 JavaFX 中无法正常工作
【发布时间】:2013-12-21 14:26:52
【问题描述】:

这是我的 sn-p:

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 Layout在设置场景的时候会自动调整大小,为什么用MiGLayout就不行呢?

我正在使用 MigLayout 4.3

【问题讨论】:

  • 我自己也遇到过类似的 MigPane 问题。似乎 MigPane 打破了一些常见的约定。我不得不改用 GridPane。好消息是 GridPane 比 GridBag 更容易使用,实际上与 MigPane 相差不远。

标签: java user-interface javafx miglayout


【解决方案1】:

所以,我提交了issue,后来找到了解决方法: 只需在stage.show() 之后添加stage.sizeToScene()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-17
    • 1970-01-01
    • 2016-06-30
    • 2016-10-17
    • 2017-09-04
    • 2012-05-16
    • 2022-11-04
    • 1970-01-01
    相关资源
    最近更新 更多