Hi, I defined:
public class FLabel extends GLabel implements Runnable{
//constructor
public FLable(......){
..........
}
public void run(){
.......
}
}
How can I call getElementAt() method in this definition? Thanks a lot!!!
Printable View
Hi, I defined:
public class FLabel extends GLabel implements Runnable{
//constructor
public FLable(......){
..........
}
public void run(){
.......
}
}
How can I call getElementAt() method in this definition? Thanks a lot!!!
The way you call any method: get a reference to an instance of the class with the method and use it:
referenceToClass.theMethodToCall(<args here>);
You need to be more specific with the details of your code to get a more specific answer.
Thank you for your answer. Here are my codes:
public class FLabel extends GLabel implements Runnable{
public FLabel(String s,GRect rect){
super(s);
this.s=s;
this.rect=rect;
setColor(Color.red);
setFont("TIMES-PLAIN-20");
}
public void run(){
while (true){
pause(15);
move(0,STEP);
if(getElementAt(getX()+getWidth()/2+1,getY())==rect) break;
}
}
private static final double STEP=1.0;
private String s;
private GRect rect;
}
How to change the bold line? Thank you.
What do you want to change it to? Can you explain what the problem is?
If you are getting compiler errors, please copy and paste here the full text of the error message.
What class and packages are you using? I don't recognize many of the methods and classes you are using.
I use acm.jar package.
I think I solved this problem. I added one Gcanvas instance like canvas to it, then I can call canvas.getElementAt() method.
Please go through the http://www.java-forums.org/forum-gui...w-members.html and BB Code List - Java Programming Forum
db