Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Aug 11th, 2004, 4:40 PM   #1
mangudai_gb
Newbie
 
Join Date: Aug 2004
Posts: 3
Rep Power: 0 mangudai_gb is on a distinguished road
import java.applet.*;
import java.awt.*;

public class Ballbewegung1 extends Applet implements Runnable
{
// Initialisierung der Variablen
int x_pos = 10; // x - Position des Balles
int y_pos = 100; // y - Position des Balles
int radius = 20; // Radius des Balles

public void init()
{
setBackground (Color.blue);
}

public void start ()
{
// Schaffen eines neuen Threads, in dem das Spiel läuft
Thread th = new Thread (this);
// Starten des Threads
th.start ();
}

public void stop()
{

}

public void destroy()
{

}

public void run ()
{
// Erniedrigen der ThreadPriority um zeichnen zu erleichtern
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

// Solange true ist läuft der Thread weiter
while (true)
{
// Verändern der x- Koordinate
x_pos ++;

// Neuzeichnen des Applets
repaint();

try
{
// Stoppen des Threads für in Klammern angegebene Millisekunden
Thread.sleep (20);
}
catch (InterruptedException ex)
{
// do nothing
}

// Zurücksetzen der ThreadPriority auf Maximalwert
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}


public void paint (Graphics g)
{
g.setColor (Color.red);

g.fillOval (x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
}

this give this message when i run it:Exception in thread "main" java.lang.NoSuchMethodError: main
mangudai_gb is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:03 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC