Very new to programming. I am trying to create a simple traffic light. 'panel' needs to stay as a 'LightShow' object but eclipse suggests that I make it of type component. I'm getting this error:
Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container
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)
//Traffic Light Show Class
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);
}
}