Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

where is this error Noobie question first time using Java

Posted on 2004-08-10
30
Medium Priority
?
237 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

885 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