Discussion:
Graphics2D drawstring compilation error
(too old to reply)
Ram Trikutam
2003-12-07 04:50:31 UTC
Permalink
Hi

I am compiling a small applet program and getting compiling errors. I
am just learning so any help is appreciated. I am on version 1.3.1_09
JDK.
****** RootApplet.java *********
import java.awt.*;

public class RootApplet extends com.sun.java.swing.JApplet {
int number;

public void init() {
number =225;
}


public void paint (Graphics screen) {
super.paint(screen);
Graphics2D screen2D = (Graphics2D) screen;
screen2D.drawstring("The square root of " +
number +
" is " +
Math.sqrt (number) , 5, 50);
}
}

*********
C:\java>javac RootApplet.java
RootApplet.java:3: cannot resolve symbol
symbol : class JApplet
location: package swing
public class RootApplet extends com.sun.java.swing.JApplet {
^
RootApplet.java:12: cannot resolve symbol
symbol : variable super
location: class RootApplet
super.paint(screen);
^
RootApplet.java:14: cannot resolve symbol
symbol : method drawstring (java.lang.String,int,int)
location: class java.awt.Graphics2D
screen2D.drawstring("The square root of " +
^
3 errors

C:\java>java -version
java version "1.3.1_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_09-b03)
Java HotSpot(TM) Client VM (build 1.3.1_09-b03, mixed mode)
Anthony Borla
2003-12-07 06:29:05 UTC
Permalink
Post by Ram Trikutam
Hi
I am compiling a small applet program and getting
compiling errors. I am just learning so any help is appreciated.
I am on version 1.3.1_09 JDK.
****** RootApplet.java *********
import java.awt.*;
public class RootApplet extends com.sun.java.swing.JApplet {
int number;
<SNIP>
Post by Ram Trikutam
*********
C:\java>javac RootApplet.java
RootApplet.java:3: cannot resolve symbol
symbol : class JApplet
location: package swing
public class RootApplet extends com.sun.java.swing.JApplet {
^
RootApplet.java:12: cannot resolve symbol
symbol : variable super
location: class RootApplet
super.paint(screen);
^
RootApplet.java:14: cannot resolve symbol
symbol : method drawstring (java.lang.String,int,int)
location: class java.awt.Graphics2D
screen2D.drawstring("The square root of " +
^
3 errors
You might want to try:

public class RootApplet extends javax.swing.JApplet {
...

Alternatively, use 'import':

import javax.swing.JApplet;
...
public class RootApplet extends JApplet {
...

or:

import javax.swing.*;
...
public class RootApplet extends JApplet {
...

I hope this helps.

Anthony Borla

Continue reading on narkive:
Loading...