gpt4 book ai didi

java - 如何将现有的 JPanel 添加到 TitledPane

转载 作者:行者123 更新时间:2023-11-30 11:03:34 26 4
gpt4 key购买 nike

我目前有一行添加到 JFrame 的 JPanel。我需要这些面板能够展开和折叠,以尽量减少 JFrame 上的困惑。

现在,我只是创建 JPanel,然后将它们添加到 JFrame。

public void addFolderSearch(FolderSearchComp fsc) {
folderCompPanel.add(fsc, folderCompPanel.getComponentCount());
remake();
}

我已经尝试将这些 FolderSearchComps(JPanel)添加到 TitledPane,然后将 TitledPane 添加到 JFrame,但 titledpane.setContent() 不会将 JPanel 作为参数。

有什么方法可以将 JPanel 添加到 TitledPane,然后将该 TitledPane 添加到 JFrame?

最佳答案

is there any swing component similar to the titledpane? or any other workaround to expand and collapse the jpanel

SwingX中有一套完整的Swing组件扩展包含标题 Pane 、任务 Pane 和可折叠 Pane 的库,仅提及您正在寻找的那些。

看看这个相关的问答:How to create expandable panels using swing? .您可能还想看看演示:SwingLabs demos

关于java - 如何将现有的 JPanel 添加到 TitledPane,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30303446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com