简体   繁体   English

使用GridBagLayout定位

[英]Positioning using GridBagLayout

As you can see in my output below, the label is displayed on top of my "next piece" grid. 正如您在下面的输出中所看到的,标签显示在我的“下一个”网格的顶部。 I know why this is happening (because my grid bag constraints are at the same location) but if I increase the y component of these constraints, my "next piece" grid is moved the the y coordinate after the larger grid. 我知道为什么会发生这种情况(因为我的网格包约束在同一个位置)但是如果我增加这些约束的y分量,我的“下一个”网格将移动到更大网格后面的y坐标。 I would like to have the "next piece" grid where it is with the label right over top of it. 我希望有一个“下一块”网格,标签就在它的顶部。

Any suggestions? 有什么建议么?

在此输入图像描述

Either

  1. Use a compound layout (placing the two components on the left in there own container and then adding that to the main container) or 使用复合布局(将两个组件放在左侧的自有容器中,然后将其添加到主容器中)或
  2. Take a look at the gridheight property of GridBagConstraints (for the other two components right of the problem area) 看一下GridBagConstraintsgridheight属性(对于问题区域右边的其他两个组件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM