gpt4 book ai didi

java - 将图像添加到 GUI

转载 作者:行者123 更新时间:2023-12-01 11:56:45 25 4
gpt4 key购买 nike

我在将照片添加到 GUI 时遇到了麻烦。我创建了一个 JPanel,并使用它来添加我的照片。但是,当我取消注释第 156 行时,除了照片之外,GUI 中的所有内容都消失了。

我指的是第 149-156 行。

http://pastie.org/private/znexgtf7uskpapd4cuaoq#146,153

最佳答案

您的 contentPane 面板使用 BorderLayout,因此当您取消注释行 contentPane.add(panel_4); panel panel_4 将替换之前设置为 BorderLayout.CENTER 的面板,在本例中为 tabbedPane

正如 documentation 中提到的对于 BorderLayout:

Each region may contain no more then one container. ..... BorderLayout interprets the absence of a string specification the same as the constant CENTER

关于java - 将图像添加到 GUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28393730/

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