MiGLayout sizing not working properly in JavaFX

不羁岁月 提交于 2020-01-17 07:11:21

问题


Here's my snippet:

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);
        }
}

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?

I'm using MigLayout 4.3


回答1:


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



来源:https://stackoverflow.com/questions/20386589/miglayout-sizing-not-working-properly-in-javafx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!