-3
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class string3 extends Applet implements TextListener{
Label lblMessage;
TextField txtText1;
String strString1="";
public void init(){
lblMessage=new Label("enter some words");
add(lblMessage);
txtText1.addTextListener(this);
}
public void paint(Graphics objG){
objG.drawString="strString 1,202,42";
}
public void textValueChanged(TextEvent objE){
strString1=txtText1.getText();
repaint();
}
}

the cmd says

C:\sample java>javac string3.java string3.java:14: cannot find symbol symbol : variable drawString location: class java.awt.Graphics objG.drawString="strString 1,202,42";

1 error

Junel
  • 17
  • 1
  • 4
  • 4
    You should not start doing GUI programming, which is hard, if you don't know the difference between an attribute and a method, and don't know how to find and read javadoc. Read an introductory Java, or even programming book, and practice with simple, console-based exercises. Also learn to indent your code, respect Java naming conventions, and choose good names for your variables. `strString1` and `txtText1` are really awful names. – JB Nizet Aug 21 '13 at 07:15

1 Answers1

2

drawString is a method and not a variable. So you need to pass the parameters to method instead of assigning them. You need to change this:

objG.drawString="strString 1,202,42";

to:

objG.drawString(strString1,202,42);
Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136