Are you using an older version of Java. I believe Swing is added to the standard classes since 1.3. If you are using an older version you can add the swing classes to the classpath (I don't know what the jar was called but it exists.) Maybe it is a better idea to use a newer JDK anyway, especially if you want to use Swing.
My guess is that you're using Visual J++ or another old IDE you found the disks for. Java's come a long way since then. Visual J++ partially supports Java version 1.1, while the current version is 1.5 -- and an awful lot has changed in the many intervening years.
Visit java.sun.com to get a brand-new Java Developer's Kit.
The J2SE 1.5 API documentation still shows Swing as a javax package.
But the original swing (swing 1.0) classes were in the package com.sun.java.swing and subpackages thereof. (They weren't shipped with the Jdk either, they were a separate download) [ June 01, 2005: Message edited by: Timmy Marks ]
Try using something else from the swing package and see what happens. You should definately be using.
just doing
is generally not considered good coding practice. Though you can try it just for trouble shooting purposes.
Chances are that the compiler can't find the swing package. Either you don't have it (by using an older version of java, as has been suggested) or it's not in your classpath.
Hello all and thanks for the swift replies. I am using jdk1.5.0_02 in a linux computer. It could be a classpath or path problem. Here's what I did in my /etc/profile
I created a "java" link to my jdk1.5.0_02 folder. It still gives me the same compile error message.
Maybe I'm wrong but the message looks different to what I get if I import a non-existant class. Could there be something else wrong with the code?
Normlly (for me atleast) I'd get: cannot find symbol symbol : class Fish location: package javax.swing import javax.swing.Fish; ...................^ (without the dots) 1 error