Solved

where is this error Noobie question first time using Java

Posted on 2004-08-10
30
222 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
Comment Utility
You probably haven't declared the variable screen.

/Nick
0
 
LVL 5

Expert Comment

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

Author Comment

by:aot2002
Comment Utility
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
 
LVL 14

Expert Comment

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

Expert Comment

by:sudhakar_koundinya
Comment Utility
java  is case sensitive language
0
 
LVL 1

Author Comment

by:aot2002
Comment Utility
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
Comment Utility
screen.drawString("Testing",10,10);
0
 
LVL 13

Expert Comment

by:Webstorm
Comment Utility
you need to specify the position :

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

Expert Comment

by:sudhakar_koundinya
Comment Utility
screendrawString("Testing",100,100) ;
0
 
LVL 14

Expert Comment

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

Expert Comment

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

Expert Comment

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

Author Comment

by:aot2002
Comment Utility
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
Comment Utility
i do have all plugins and all i see is a grey screen
0
 
LVL 14

Expert Comment

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

Did not get you
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:aot2002
Comment Utility
in the webpage i should see "testing"
0
 
LVL 4

Expert Comment

by:JK2429
Comment Utility
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
Comment Utility
appletviewer rootapplet.java

is this working??
0
 

Expert Comment

by:koushik_ms
Comment Utility
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
Comment Utility
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
Comment Utility
>>   <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
Comment Utility
root applet not found error on status bar
0
 
LVL 1

Author Comment

by:aot2002
Comment Utility
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
Comment Utility
<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
Comment Utility
Try:

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

Author Comment

by:aot2002
Comment Utility
0
 
LVL 14

Expert Comment

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

Author Comment

by:aot2002
Comment Utility
ok did it and recompiled it
0
 
LVL 1

Author Comment

by:aot2002
Comment Utility
Java(TM) 2 SDK, Standard Edition
                               Version 1.4.2

to compile this on windows XP pro
0
 
LVL 1

Author Comment

by:aot2002
Comment Utility
i am able to see ur applet.

what seems to be the issue ?
please help !
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
json example 39 110
Starting to learn JAVA, 7 47
@SBGen Method 3 25
starter POM and spring-boot-starter,  spring-boot-web 2 10
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now