如何在JAVA上相应地操作GridLayout设置? [英] How to manipulate GridLayout settings accordingly on JAVA?

查看:181
本文介绍了如何在JAVA上相应地操作GridLayout设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个setLayout(新的GridLayout(5,5,3,3));

I have a setLayout(new GridLayout(5,5,3,3));

5行和5列。在第一行我想要一个大行。你知道如何在excel中合并单元格。所以我只想在第一行合并5列。我在第一行放置了一个JLabel,我非常讨厌每个网格单元需要多个JLabel,并确保间距很好。

5 rows and 5 columns. On the first row I want one big row. You know how in excel, where you would merge cells. So I just want to merge the 5 columns only on the first row. I am putting a JLabel on the first row, and its very annoying that I need to have multiple JLabels for each grid cell and make sure spacing works out well.

有没有办法在GridLayout上执行此操作?或者我严格坚持5行和5列?

Is there a way to do this on GridLayout? Or I am stuck with 5 rows and 5 col strictly?

推荐答案

GridBagLayout 可以做到这一点。或者,您可以使用嵌套布局:将第一行添加到 NORTH 中api / java / awt / BorderLayout.htmlrel =nofollow> BorderLayout 和剩余的 GridLayout CENTER 。另请参见 布局管理员可视指南

GridBagLayout can do this. Alternatively, you can use nested layouts: add the first row to the NORTH of BorderLayout and remaining GridLayout to the CENTER. See also A Visual Guide to Layout Managers.

附录: MiGLayout 也很好值得一看这个背景。 Web Start演示特别吸引人,有关 合并和拆分单元 <的手册部分/ a>可能有用。

Addendum: MiGLayout is also well worth a look in this context. The Web Start demo is particularly appealing, and the manual section on Merging and Splitting Cells may be useful.

这篇关于如何在JAVA上相应地操作GridLayout设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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