【问题标题】:How to implement JSplitPane in the BorderLayout?如何在 BorderLayout 中实现 JSplitPane?
【发布时间】:2010-12-31 15:15:17
【问题描述】:

嗨,

如何使用 JSplitPane 以便它们显示在 BorderLayout 的边框中???

这样我就可以调整每个尺寸(北、东、西、南、中)的大小。

谢谢

【问题讨论】:

    标签: java swing layout border jsplitpane


    【解决方案1】:

    因此,您实际上并不需要 BorderLayout。您可以将拆分窗格添加在一起以获得该效果。因为JSplitPane只支持拆分2个组件,所以需要垂直2个JSplitPane,在第二个垂直JSplitPane内需要2个JSplitPane

    JSplitPane horizontal1 = new JSplitPane(
        JSplitPane.HORIZONTAL_SPLIT, yourCenterPanel, yourEastPanel);
    JSplitPane horizontal2 = new JSplitPane(
        JSplitPane.HORIZONTAL_SPLIT, yourWestPanel, horizontal1);
    JSplitPane vertical1 = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT, horizontal2, yourSouthPanel);
    JSplitPane vertical2 = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT, yourNorthPanel, vertical1);
    whateverPlaceYouWant.add(vertical2);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-13
      • 2012-03-04
      相关资源
      最近更新 更多