gpt4 book ai didi

java - 与 miglayout 对齐错误

转载 作者:行者123 更新时间:2023-12-01 15:00:52 25 4
gpt4 key购买 nike

在 jframe 中,我使用 miglayout 作为 jpanel 的主要位置。

在左侧面板中,我有2个jpanel,我使用boxlayout。

ComponentPanel 位于左上角位置,PropertyPanel 位于左下角位置。

    leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));

leftPanel.setMinimumSize(new Dimension(600, 600));

add(leftPanel, BorderLayout.WEST);

componentPanel = new ComponentPanel();
propertyPanel = new PropertyPanel();

在 propertyPanel 构造函数中,我这样做

setLayout(new MigLayout("debug"));

我明白了

mig layout

为什么面板设置在右侧?

如果我动态添加,则会添加一些空间。

enter image description here

我尝试对 miglayout 构造函数使用 fill,但没有成功。

绿色的是左侧面板红色的是ComponentPanel

http://imagepaste.nullnetwork.net/img/1354548433miglayout3.jpg

最佳答案

使用 BorderLayout 而不是 BoxLayout 似乎更好...

leftPanel.setLayout(new BorderLayout());
leftPanel.add(componentPanel, BorderLayout.NORTH);
leftPanel.add(propertyPanel,BorderLayout.SOUTH);

BoxLayout问题?

关于java - 与 miglayout 对齐错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13674444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com