Solved

where is this error Noobie question first time using Java

Posted on 2004-08-10
30
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

734 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