生长比growx更大的表 [英] Grow table larger than growx

查看:151
本文介绍了生长比growx更大的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按如下方式配置我的布局:

I have configured my layout like that:

    panel.add(addButtons(), "wrap");    
    panel.add(showTable(), "growx, wrap");

所以首先我要添加一个按钮组,然后我想把我的桌子扩大到像它可以然后将下一个组件包装在下一个行中。

So at first I am adding a button group and then I would like to grow my table as large as it can and then wrap the next component in the next "line".

但是,我的gui看起来像这样:

However, my gui looks like that:

在这里显然无法从表中看到任何值。因此,如何增加表格以便可以看到每个值?

Here you clearly cannot see any values from the table. Therefore, how to grow the table so that each value can be seen?

我感谢您的回答!

推荐答案


在这里你显然看不到表中的任何值。因此,如何增长表格以便可以看到每个值?

正如我在评论中所说的那样,我认为您的问题不是关于列(首选|最大|最大)大小,而是布局管理器的默认行为: MigLayout 。正如此答案中所述,默认情况下 MigLayout 中的行不会填充所有可用宽度,但只需显示最长行(基于组件宽度)。如果在实例化布局时启用调试功能,则可以看到这一事实:

As I've said in my comment, I don't think your problem is about columns (preferred | min | max) sizes but the default behavior of your layout manager: MigLayout. As stated in this answer by default rows in MigLayout doesn't fill all available width but just the necessary to display the longest row (based on components width). You can see this fact if you enable "debug" feature when you instantiate your layout:

MigLayout layout = new MigLayout("debug");

据我了解你的问题,你需要两者的组合 growx fillx 约束。第一个是组件约束,另一个是布局约束。

As I understand your question you need a combination of both growx and fillx constraint. The first one is a component constraint and the other one is a layout constraint.

话虽如此,pelase考虑以下进展。

That being said, pelase consider the following progression.

代码段

MigLayout layout = new MigLayout("debug");
JPanel panel = new JPanel(layout);
panel.add(buttonsPanel, "wrap");
panel.add(scrollPane);

屏幕截图

代码段

MigLayout layout = new MigLayout("debug");
JPanel panel = new JPanel(layout);
panel.add(buttonsPanel, "wrap");
panel.add(scrollPane, "growx"); // Note "growx" here

屏幕截图

代码段

MigLayout layout = new MigLayout("debug, fillx"); // Note "fillx" here
JPanel panel = new JPanel(layout);
panel.add(buttonsPanel, "wrap");
panel.add(scrollPane, "growx"); // Note "growx" here

屏幕截图

这篇关于生长比growx更大的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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