java swing component cannot be resolved

前端 未结 9 1989
灰色年华
灰色年华 2020-12-11 16:43

I took the following code from a tutorial:

import javax.swing.*;
import java.util.Date;

public class SwingGUI {

    public static void main( String[] args          


        
相关标签:
9条回答
  • 2020-12-11 17:07

    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.

    0 讨论(0)
  • 2020-12-11 17:13

    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.

    0 讨论(0)
  • 2020-12-11 17:14

    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.

    0 讨论(0)
提交回复
热议问题