Solved

where is this error Noobie question first time using Java

Posted on 2004-08-10
30
231 Views
Last Modified: 2010-03-31
C:\Program Files\Apache Group\Apache\htdocs\school>javac rootapplet.java
rootapplet.java:17: cannot resolve symbol
symbol  : variable screen
location: class rootapplet
        screen.drawString("Testing");
        ^
1 error
0
Comment
Question by:aot2002
  • 12
  • 10
  • 4
  • +4
30 Comments
 
LVL 9

Accepted Solution

by:
Nick_72 earned 250 total points
ID: 11764081
You probably haven't declared the variable screen.

/Nick
0
 
LVL 5

Expert Comment

by:TrekkyLeaper
ID: 11764087
The variable "screen" is either not defined or out of scope.
0
 
LVL 1

Author Comment

by:aot2002
ID: 11764190
well would this be a path issue as the main path is
c:\jdk\

if not then how can i clear the variable screen




import java.awt.*;

public class rootapplet extends javax.swing.JApplet {
      String parameter1;
      String parameter2;
      String parameter3;

      public void init() {
            parameter1 = getParameter("adjective1");
            parameter2 = getParameter("adjective2");
            parameter3 = getParameter("adjective3");
            
            }
            
      public void paint(Graphics Screen) {
      
      screen.drawString("Testing");
      
      }
      
      
   }
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764334
>>public void paint(Graphics Screen) {  should be
public void paint(Graphics screen) {
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764346
java  is case sensitive language
0
 
LVL 1

Author Comment

by:aot2002
ID: 11764431
ok same error



C:\Program Files\Apache Group\Apache\htdocs\school>javac rootapplet.java
rootapplet.java:17: cannot resolve symbol
symbol  : method drawString (java.lang.String)
location: class java.awt.Graphics
        screen.drawString("Testing");
              ^
1 error





import java.awt.*;

public class rootapplet extends javax.swing.JApplet {
      String parameter1;
      String parameter2;
      String parameter3;

      public void init() {
            parameter1 = getParameter("adjective1");
            parameter2 = getParameter("adjective2");
            parameter3 = getParameter("adjective3");
            
            }
            
      public void paint(Graphics screen) {
      
      screen.drawString("Testing");
      
      }
      
      
   }            
   

   
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 11764457
screen.drawString("Testing",10,10);
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 11764462
you need to specify the position :

    screen.drawString("Testing",x,y);
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764464
screendrawString("Testing",100,100) ;
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764474
screen.drawString("Testing",100,100) ;
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 11764519
>> screen.drawString("Testing",100,100) ;
as i said.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764549
yep at same time we both gave the answer. the first one has type-o error  :-)
0
 
LVL 1

Author Comment

by:aot2002
ID: 11764572
ok no error but shouldnt i see somtheing in the page?

 Directory of C:\Program Files\Apache Group\Apache\htdocs\school

08/10/2004  12:20 PM    <DIR>          .
08/10/2004  12:20 PM    <DIR>          ..
08/10/2004  12:20 PM                63 index.html
08/10/2004  12:19 PM                63 index.html.bak
08/10/2004  12:19 PM               684 rootapplet.class
08/10/2004  12:19 PM               424 rootapplet.java
08/10/2004  12:18 PM               422 rootapplet.java.bak
08/10/2004  11:48 AM               156 var.java
08/10/2004  11:48 AM               284 Variable.class



<applet code="rootapplet.class" height=100 width=300>
<applet>




==========================================



import java.awt.*;

public class rootapplet extends javax.swing.JApplet {
      String parameter1;
      String parameter2;
      String parameter3;

      public void init() {
            parameter1 = getParameter("adjective1");
            parameter2 = getParameter("adjective2");
            parameter3 = getParameter("adjective3");
            
            }
            
      public void paint(Graphics screen) {
      
      screen.drawString("Testing", 100,100);
      
      }
      
      
   }            
   

   
0
 
LVL 1

Author Comment

by:aot2002
ID: 11764580
i do have all plugins and all i see is a grey screen
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11764615
>> ok no error but shouldnt i see somtheing in the page?

Did not get you
0
 
LVL 1

Author Comment

by:aot2002
ID: 11764642
in the webpage i should see "testing"
0
 
LVL 4

Expert Comment

by:JK2429
ID: 11765381
drawString requires 3 parameters:
abstract  void drawString(AttributedCharacterIterator iterator, int x, int y)
Draws the text given by the specified iterator, using this graphics context's current color.
abstract  void drawString(String str, int x, int y)
Draws the text given by the specified string, using this graphics context's current font and color.

public void paint (Graphics screen)
{
screen.drawString("abc", 5,5);
}

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11765414
appletviewer rootapplet.java

is this working??
0
 

Expert Comment

by:koushik_ms
ID: 11765616
Hi aot2002,
  Try increasing the value of height parameter in the html code.
Change ...

>>   <applet code="rootapplet.class" height=100 width=300>
>>  <applet>

to
  <html><body>
  <applet code="rootapplet.class" height=300 width=300>
 </applet></body></html>

Otherwise, use smaller values for co-ordinates in drawString method call:
Change
> screen.drawString("Testing", 100,100);
to
screen.drawString("Testing", 10,10);

like Webstorm said.

Cheers!
K
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11765805
there is no difference between screen.drawString("Testing", 100,100);
and screen.drawString("Testing", 10,10);

it is afterall a matter of position. only thing he/she need to do is increase the size of applet
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11766069
>>   <applet code="rootapplet.class" height=100 width=300>
>>  <applet>

to
  <html><body>
  <applet code="rootapplet.class" height=300 width=300>
 </applet></body></html>

coming to above statements both are valid

the second one need to declare in html page where as user can declare in source file itself for first option

if he choose first optioon then
appletviewer rootapplet.java works
appletviewer rootapplet.html works

if user wants to see the output in browser itself

iexplore  rootapplet.html works

Best Regards
Sudhakar





0
 
LVL 1

Author Comment

by:aot2002
ID: 11768264
root applet not found error on status bar
0
 
LVL 1

Author Comment

by:aot2002
ID: 11768419
class rootapplet not found

but yet it is in the directory
 Directory of C:\Program Files\Apache Group\Apache\htdocs\school

08/10/2004  07:24 PM    <DIR>          .
08/10/2004  07:24 PM    <DIR>          ..
08/10/2004  07:23 PM                64 index.html
08/10/2004  06:50 PM                63 index.html.bak
08/10/2004  07:24 PM               498 rootapplet.class
08/10/2004  07:24 PM               430 rootapplet.java
08/10/2004  12:19 PM               424 rootapplet.java.bak
08/10/2004  11:48 AM               156 var.java
08/10/2004  11:48 AM               284 Variable.class
0
 
LVL 1

Author Comment

by:aot2002
ID: 11768505
<applet code="rootapplet.class" height=300 width=300>
</applet>





import java.awt.*;

public class rootapplet extends javax.swing.JApplet {
      String parameter1;
      String parameter2;
      String parameter3;

      public void init() {
            //parameter1 = getParameter("adjective1");
            //parameter2 = getParameter("adjective2");
            //parameter3 = getParameter("adjective3");
            
            }
            
      public void paint(Graphics screen) {
      
      screen.drawString("abc", 5,5);
      
      }
      
      
   }            
   

   
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 11768714
Try:

<applet code="rootapplet.class" codebase="./" height=300 width=300>
</applet>
0
 
LVL 1

Author Comment

by:aot2002
ID: 11768730
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11769541
i am able to see ur applet. place string in some other position say 25,25
0
 
LVL 1

Author Comment

by:aot2002
ID: 11769716
ok did it and recompiled it
0
 
LVL 1

Author Comment

by:aot2002
ID: 11769724
Java(TM) 2 SDK, Standard Edition
                               Version 1.4.2

to compile this on windows XP pro
0
 
LVL 1

Author Comment

by:aot2002
ID: 11788637
i am able to see ur applet.

what seems to be the issue ?
please help !
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question