问题标签 [gridbaglayout]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
3734 浏览

java - GridBagLayout 中的 JScrollPanes 随机调整大小

这对你们来说是一个艰难的过程:)

基本上我有一个 GridBagLayout 有 2 列:一个列表包裹在每个滚动窗格中。滚动窗格在两个方向上拉伸。

如果我逐渐降低此面板的高度(通过拖动窗口的边缘),我会看到滚动窗格上发生“随机”调整大小:

  • 当第一个的 Hscroll 条出现时,第二个的宽度会减小

  • 然后,第二个的宽度又无缘无故地缩小了……

如果我不包装我的组件,请不要出现这种行为。


如果你用树 替换右手列表,它的行为会有所不同:将窗口的高度缩小到 380-ich 像素以下,树的大小会被调整......

如果我不包装我的组件,那么如果您继续调整窗口大小,树就会重新调整大小!

你们知道发生了什么吗???

PS:我试图构建的实际布局比这个例子更复杂。与此同时,我使用 SpringLayout 来做我想做的事,但它需要很多(不是那么漂亮)的东西来设置

0 投票
2 回答
6548 浏览

java - 将 jframe 设置为 gridbaglayout 时,jpanel 无法很好地显示

下面的程序是用 gridbaglayout 将 jpanel 定位在 jframe 的左上角,但在 jframe 的中心显示一个非常小的框。当我将 jframe 的布局设置为 null 时,jpanel 显示正常。有人能告诉我为什么 jpanel 用 gridbaglayout 压缩到框架的中心吗?我真的需要使用gridbag。请帮忙

0 投票
2 回答
1264 浏览

java - JScrollPane with JList does not scroll in GridBagLayout

I have a couple of Jlist within jscrollpanes in a gridbaglayout. The amount of entries in 1 Jlist is more than fits in the visible area of the Jlist. But the jscrollpane does not provide scrolling functionality.

I used to have the all of the jscrollpanes enclosed in a jpanel, at that time scrollpane provided the correct scrolling functionality.

I have the preferredsize of the Jlist set to [0,0]. The layout of the Jlist is correct. I can set the preferredsize of the JList to an explicit value of for example [80,300]. This causes JList to be scrollable partially. The real size of the JLIst, if it would be visible completely, is much longer.

Somehow I guess the gridbaglayout is resizing my Jlist in a way that the Jlist is not able to provide the correct size it has to the scrollpane.

How do I make the gridbaglayout and Jlist within jscrollpanes work together?

0 投票
1 回答
262 浏览

java - GridBagLayout 中的对齐(小程序)

我对 GridBagLayout 有疑问。我的组件不想看起来像我想要的那样;)我想做这样的布局:

在此处输入图像描述

我写了一段代码:

结果看起来像这样,“几乎”很好;]

在此处输入图像描述

你知道吗,如何定制它?

提前致谢, 马尔辛

// 编辑

嘿,我用 MigLayout 解决了一个问题(感谢 mKorbel)。代码如下所示(要删除跟踪行,请从构造函数中删除调试):

(ps如果你不想设定上限(10000),你可以写hmin x,hmax y ...我不需要它;))

0 投票
2 回答
414 浏览

java - 如何使用网格包布局将三个标签添加到框架?

尝试使用 GridBagLayout。

我有一个名为 buildLabel 的方法。这将创建三个标签。另一种方法称为 addComponentsToFrame。这将构建框架并创建一个面板。它还将三个标签添加到面板中。现在我想展示我所做的。如何显示框架。这是我的代码!

0 投票
2 回答
5324 浏览

java - GridBagLayout 不显示 JTextArea,并在中心显示面板

在下面的代码中,当我将 JTextArea 添加到主面板时,它没有显示出来。当我添加控制面板时,它显示在中心,而不是边缘。我是 GridBagLayout 的新手,所以我假设我缺少一些简单的东西。

编辑:这就是约束如何照顾您的建议。textArea 仍然没有出现。

0 投票
2 回答
46795 浏览

java - 如何在 GridBagLayout 单元格内左对齐或右对齐?

我看到它GridBagLayout的位置是在单元格内居中对齐的孩子。如何左对齐或右对齐?

更新

构建代码(我知道我可以重用c

0 投票
1 回答
2885 浏览

java - 如何在 Java 中锁定 gridLayout 的纵横比?

是否有一种简单的方法可以在 Java Swing 中锁定 GridLayout 组件的纵横比?还是应该在包含该布局的 JPanel 上完成?

0 投票
2 回答
3209 浏览

java - 使用 GridBagLayout 将 JScrollBar 添加到 JPanel

我这样做的全部目的是得到这样的东西:

IMG

我希望我的技能列表滚动类似于在 Excel 中冻结电子表格的第一行。

这是我第一行的代码。

这是解析(commandString - 来自服务器/数据库的技能回复)的代码

如您所见,它完美地添加了所有内容,但滚动条没有连接到任何东西。我对此束手无策。我尝试通过向其添加技能面板内容来使用 JScrollPane,但无论我做什么它都不会显示。

任何建议或帮助将不胜感激。我希望我根据需要保持简短(代码)。如果我可以包含其他任何内容以提供更多帮助,请告诉我。谢谢。

0 投票
2 回答
456 浏览

java - GridBagLayout 中的组件布局不如预期

在此我添加了一些标签、单选按钮、文本字段。单选按钮和标签正在按我想要的方式显示,但文本字段没有正确显示。谁能告诉我如何让文本字段覆盖更多空间?

这就是gui的显示方式