I took the following code from a tutorial:
import javax.swing.*;
import java.util.Date;
public class SwingGUI {
public static void main( String[] args
I get this problem too. unfortunately to resolve it I was needed to install my eclipse. but I think that the problem was incompatibility between JRE and JAVA version in Eclipse.
I used JRE supported JAVA8 when my project (and my eclipse indigo) can't upgrade to JAVA8. Updating to another eclipse that can support java 8 solve the problem.
am new here. I had this problem and it took me 2 days of research. I solved it by adding an external JAR file that contains all the required components to my Eclipse. Right-click project>>Buildpath>>Configure build path>> Add external JARS and browse for the JAR file on your computer. The JAR file can be downloaded here http://www.java2s.com/Code/Jar/j/Downloadjsdgstubsjre15jar.htm Hope this helps someone out there.
Just guessing, but it matches the problem you describe:
This problem can arise when your own package contains a class that is called JLabel
. The local class will then shadow the imported JLabel
-class from the javax.swing
-package and it might not have the same class-hierarchy as the original class.
To sum it up: it usaually is a bad idea to name ones own classes like existing JDK-classes.