【问题标题】:Stacking JPanels in the same direction以相同方向堆叠 JPanel
【发布时间】:2015-05-31 11:12:48
【问题描述】:

我想在同一方向上堆叠 JPanel。 我已经搜索过这个并找不到任何东西。显示的结果意味着“重叠”。

这就是我的意思:

我想将第二个 JPanel 堆叠在第一个 JPanel 下方。使用时:add(BorderLayout.NORTH) 在两种布局上都会重叠。

感谢您的帮助,谢谢!

【问题讨论】:

标签: java swing jpanel layout-manager


【解决方案1】:

我通常如何编写类似这样的特定代码,我喜欢使用 GridLayout,并将其设置为 2 行和 1 列。

  //this will go with the boiler plate
 this.setlayout(new GridLayout(2,1));

这应该可以解决两个 JPanel 的问题,如果需要,您可以随时向行添加更多内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-17
    • 2014-03-12
    • 2021-04-30
    相关资源
    最近更新 更多