java.lang.IllegalArgumentException: adding a window to a container
来源:互联网 发布:淘宝销量排行榜查询 编辑:程序博客网 时间:2024/05/17 03:10
1、错误描述
Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a containerat java.awt.Container.checkNotAWindow(Container.java:490)at java.awt.Container.addImpl(Container.java:1091)at java.awt.Container.add(Container.java:1005)at javax.swing.JFrame.addImpl(JFrame.java:567)at java.awt.Container.add(Container.java:417)at com.you.cmdp.frame.CheckBox.<init>(CheckBox.java:42)at com.you.cmdp.frame.CheckBox.main(CheckBox.java:62)
2、错误原因
public CheckBox(){frame.setBounds(100, 100, 400, 300);frame.setFont(font);frame.setForeground(Color.WHITE);frame.setBackground(Color.BLACK);add(frame);cbOne.setText("第一节");cbTwo.setText("第二节");cbThree.setText("第三节");cbFour.setText("第四节");panel.add(cbOne);panel.add(cbTwo);panel.add(cbThree);panel.add(cbFour);frame.add(panel);}构造函数中,继承了JFrame,但是不会再次添加add(frame)
3、解决办法
public CheckBox(){frame.setBounds(100, 100, 400, 300);frame.setFont(font);frame.setForeground(Color.WHITE);frame.setBackground(Color.BLACK);//add(frame);cbOne.setText("第一节");cbTwo.setText("第二节");cbThree.setText("第三节");cbFour.setText("第四节");panel.add(cbOne);panel.add(cbTwo);panel.add(cbThree);panel.add(cbFour);frame.add(panel);}
0 0
- java.lang.IllegalArgumentException: adding a window to a container
- java.lang.IllegalArgumentException: adding a window to a container
- Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container
- java.lang.IllegalArgumentException: adding container's parent to itself
- Adding a Floating Panel to a Window
- java.lang.IllegalArgumentException: Removing a detached instance
- java.lang.IllegalArgumentException: Removing a detached instance
- java.lang.illegalargumentexception view not attached to window manager 解决
- java.lang.IllegalArgumentException: View not attached to window manager
- java.lang.IllegalArgumentException: View not attached to window manager
- java.lang.IllegalArgumentException: View not attached to window manager
- java.lang.IllegalArgumentException - not attached to window manager
- java.lang.IllegalArgumentException: View not attached to window manager
- Caused by: java.lang.IllegalArgumentException: you must specify a way to create the tab indicator.
- java.lang.IllegalArgumentException: you must specify a way to create the tab content
- java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with ...
- Caused by: java.lang.IllegalArgumentException: prefix wsdp is not bound to a namespace
- Java.lang.IllegalArgumentException: prefix wsdp is not bound to a namespace。
- 声明ViewHolder(或Handler)内部类时,建议使用static关键字的原因
- Arrays.tostring和a.toString返回的问题
- HTML5canvas时钟实例
- 框架开发之Java注解的妙用
- C++构造函数进行类型转换
- java.lang.IllegalArgumentException: adding a window to a container
- Java public private and protected
- Linux系统中文件下的Access/Modify/Change
- programme
- 三层架构和MVC模式
- 数字图像处理的基本概念
- 记录一次因为redis aof rewrite重写导致的运维过程
- Java动态代理技术-我的浅显认识
- JSON学习笔记