Results 1 to 6 of 6
- 09-21-2012, 10:02 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 4
- Rep Power
- 0
- 09-21-2012, 10:08 PM #2
Re: How to call getElementAt() method in new class definition?
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.If you don't understand my response, don't ignore it, ask a question.
- 09-21-2012, 10:35 PM #3
Member
- Join Date
- Sep 2012
- Posts
- 4
- Rep Power
- 0
Re: How to call getElementAt() method in new class definition?
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.
- 09-21-2012, 10:42 PM #4
Re: How to call getElementAt() method in new class definition?
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.If you don't understand my response, don't ignore it, ask a question.
- 09-22-2012, 04:37 AM #5
Member
- Join Date
- Sep 2012
- Posts
- 4
- Rep Power
- 0
Re: How to call getElementAt() method in new class definition?
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.
- 09-22-2012, 05:12 AM #6
Re: How to call getElementAt() method in new class definition?
Please go through the Guide For New Members and BB Code List - Java Programming Forum
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Inner class method call
By d915172 in forum New To JavaReplies: 3Last Post: 11-11-2010, 09:40 PM -
Trying to call a method from sub class
By TheNewGuy in forum New To JavaReplies: 4Last Post: 10-17-2010, 07:08 AM -
how call from inner class(anonymous or not), a method of parent class?
By lse123 in forum AWT / SwingReplies: 2Last Post: 05-01-2010, 08:59 AM -
How to call a method from another class?
By jboy in forum New To JavaReplies: 8Last Post: 09-09-2009, 07:29 AM -
How to call a class within a method
By Manfizy in forum New To JavaReplies: 3Last Post: 03-19-2009, 12:34 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks