Error: The import java.swing cannot be resolved [in drJava]
Hello, I decided to make an applet in java and wanted to use drJava for it. I installed the program and the JDK. Then, after making a code to start from, I ran into a problem.
This is the code:
Code :
import java.swing.JApplet;
import java.awt.*;
public class FirstAppletDrawing extends Applet{
public void paint (Graphics page){
setBackground (Color.cyan); //background color
page.setColor (Color.gray); //Robot head color
page.drawRec (3,4,20,20); //Robot head
}
}
When I try to compile it, the first error I get is: Error: The import java.swing cannot be resolved
I thought that I may be doing something wrong, so I decided to try and make a simpler program:
Code :
public class Simple{
public static void main (Strings[] args){
int future = 5;
int past = 1;
int present = future - past;
System.out.println("Our future is " + future + ", our past is " + past +
", and our present is" + present);
}
}
When I tried to compile that, I go this: Error: Strings cannot be resolved to a type
And that's basically from the book. Am I missing something or doing something wrong?
Re: Error: The import java.swing cannot be resolved [in drJava]
java.swing
Here's the issue: the swing package isn't in the java package, it's in the javax package. So, you need to import swing from javax, not java. :)
Re: Error: The import java.swing cannot be resolved [in drJava]
java.swing
Here's the issue: the swing package isn't in the java package, it's in the javax package. So, you need to import swing from javax, not java. :)
Quote:
Strings cannot be resolved to a type
I don't know what's causing that...
Edit: Sorry for the double post; don't know why that happened...
Re: Error: The import java.swing cannot be resolved [in drJava]
Thanks! I started looking though the two and found the little problems! Your solution was a great hint!
Re: Error: The import java.swing cannot be resolved [in drJava]
That's good! Good luck on your program! :)