是否可以使 GridLayout 的组件大小不相等?

发布于 2024-09-11 23:37:54 字数 176 浏览 2 评论 0原文

GirdLayout 使一堆组件大小相等。这意味着最大尺寸的组件将定义所有组件的尺寸。是否可以根据每个组件的内部组件来确定其大小?

编辑:如果不可能,我怎样才能获得与 GridLayout 相同的效果,但每个组件的大小基于其内部组件。

GirdLayout makes a bunch of components equal in size. That means that the biggest sized component will define the size for all components. Is it possible to make each component's size based on their inner-components instead?

EDIT: If it's not possible, how could I get the same effect as a GridLayout but with each component's size based on their inner-components.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无人问我粥可暖 2024-09-18 23:37:54

不,您必须为此使用不同的布局管理器。 GroupLayout 将是一个选项。

No, you'll have to use a different layout manager for that. GroupLayout would be an option.

少钕鈤記 2024-09-18 23:37:54

不,所有电池在设计上都是平等的。

No, all cells are equal by design.

长不大的小祸害 2024-09-18 23:37:54

这是不可能的,但您可以在每个单元格中使用嵌套组件。例如,如果您不希望 JButton 扩展到单元格大小,请将其添加到 Jpanel,然后添加 JPanel > 到细胞。

It's not possible, but you can use nested components in each cell. For example, if you don't want a JButton to expand to the size of a cell, add it to a Jpanel, then add the JPanel to the cell.

酷炫老祖宗 2024-09-18 23:37:54

也许 GridBagLayout 就是您所需要的。

Maybe a GridBagLayout is what you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文