这是我的片段:
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
最佳答案
所以,我提交了 issue后来找到了解决方法:
只需在 stage.show()
之后添加 stage.sizeToScene()
即可。
关于java - MiGLayout 大小调整在 JavaFX 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20386589/