This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Applets and Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applets and Threads" Watch "Applets and Threads" New topic

Applets and Threads

Rik Sweeney
Ranch Hand

Joined: Sep 04, 2001
Posts: 36
I've got a problem with my applet. I want to create a new object which extends thread. While that object is active it continuously calls the paint method of the applet. However upon compilation I'm told that I the non-static method cannot be called from a static context. Here's a snippet of the code:
class Projectile extends Thread {
int x,y;
boolean exists;
public Projectile(int x, int y) {
public void run() {
while (exists) {
if (x>640) exists=false;
try {
catch (InterruptedException e) {}
The draw method in the applet War just calls repaint(). I'm informed that draw isn't static and I can't make it static since repaint() cannot be overriden to be static. What am I doing wrong? Any suggestions would be appreciated.
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi ,
i was looking at ur code.whats the problem...
u can instantiate ur applet class and then can call the draw() method. it wont give u any error..
i hope ,i got correct understanding of ur question
I agree. Here's the link:
subject: Applets and Threads
Similar Threads
Bouncing balls
Instance of Graphics ,g , can't be recognized in applen
why can't I access my variable?
Hey ranchers...a lil help here plz
Applet/ Animation/ repaint-update-paint ?