作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
拜托各位,我有两个分割 Pane ,比如说 Pane A 和 Pane B,我在 Pane A 上放置了一个按钮,这样如果单击该按钮, Pane A 就会隐藏, Pane B 就会变得可见,但每次我尝试这样做时我收到一个错误,上面写着:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Do not use this method
at net.java.dev.designgridlayout.DesignGridLayoutManager.removeLayoutComponent(DesignGridLayoutManager.java:122).
最佳答案
描述不足以给出深刻的答案。但基于documentation of the method that causes the error ,似乎根本不支持从这样的布局中删除组件。
您可以使用不同的布局管理器。也许是CardLayout可能会有帮助。如有疑问,应该总是可以引入额外的容器。我将尝试在这里勾勒出这个想法,尽管没有人知道您的代码是什么样的:
class GUI {
private JPanel containerA = new JPanel(new GridLayout(1,1));
void init() {
...
// Here "grid" is the component that has the DesignGridLayout:
grid.add(containerA);
containerA.add(splitPaneA);
}
void whenTheButtonIsClicked() {
containerA.removeAll();
containerA.add(splitPaneB);
containerA.revalidate();
}
}
关于java - 在单个 jframe 上交换两个不同的分割面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24107027/
我是一名优秀的程序员,十分优秀!