Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个组件,我希望它们都填充MigLayout中的同一个单元格:
例如,我想给这两个组件约束是这样的:
cell 0 0 1 1, push, grow
并让它们在内部完全重叠放置cell 0 0
cell 0 0
(如果我只使用上面的代码,它们最终会在单元格中并排共享空间)
为了实现这一点,我必须向MigLayout约束添加什么?
我最终通过在 MigLayout 中给第一个组件一个id来解决这个问题:
cell 0 0 1 1, push, grow, id myid
然后使用第一个组件的边界(使用 id 引用)将第二个组件显式定位在第一个组件的顶部:
pos myid.x myid.y myid.x2 myid.y2
将它们放置在具有 CardLayout 的面板中,并在必要时进行交换。