编程的新手。我正在尝试创建一个简单的交通信号灯。 “面板”需要保留为“ LightShow”对象,但是日食表明我使它成为类型组件。我收到此错误:
线程“ main”中的异常java.lang.IllegalArgumentException:向容器添加窗口
at java.desktop/java.awt.Container.checkNotAWindow(Container.java:512) at java.desktop/java.awt.Container.addImpl(Container.java:1115) at java.desktop/java.awt.Container.add(Container.java:436) at guiPpTrafficLights.TrafficLightShow.main(TrafficLightShow.java:15)
//交通信号灯表演班
import javax.swing.JFrame;
public class LightShow extends JFrame
{
public static void main (String[] args)
{
JFrame frame = new JFrame("Light");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
LightShow panel = new Lightshow();
```````````````````````````````````````````````````````````
frame.getContentPane().add(panel); \\Error happening here.
```````````````````````````````````````````````````````````
frame.pack();
frame.setVisible(true);
}
}