java - 如何将 IDE 创建的 JPanel 更改为自定义创建的 JPanel?
问题描述
我想在我的 UI 中更改一个特定的 JPanel。
public Tester() {
this.setSize(800,800);
this.setContentPane(mainPanel); // A created panel using Intellij IDE
otherPanel = new MyPanel(); // A custom created panel without the use of Intellij
changePanelButton.addActionListener(e -> {
changePanel = otherPanel // Not Working
});
}
我不能使用 JFrame 中的 setContentPane,因为它会更改框架的所有内容,而不仅仅是我想要更改的面板。
解决方案
推荐阅读
- angular - 如何识别哪个组件/服务抛出了错误,同时使用全局 HTTP 拦截器作为 Angular 中的错误处理程序?
- sql - dolphindb 支持哪些 SQL 语句?
- powershell - 如何将文件名添加到文本文件(开头)?
- django - Django docstring 和 Sphinx 的未知解释文本角色“设置”
- php - 带过滤器的数据库类
- node.js - 温斯顿最新版本代码未创建日志文件
- excel - 使用 VBA 从 Zip 中删除一些特定文件
- google-apps-script - 向下合并具有相同值的单元格
- python-3.x - 从前一个调用的另一个函数访问一个函数的本地环境
- ios - 值更改时快速重新加载视图