hello!
i need some help to transform this animation which is in an applet to a Jframe :)
the code to the applet looks like this:
import java.applet.*;
import java.awt.*;
public class Ballbewegung1 extends Applet implements Runnable
{
int x_pos = 10;
int y_pos = 100;
int radius = 20;
public void init()
{
setBackground (Color.blue);
}
public void start ()
{
Thread th = new Thread (this);
th.start ();
}
public void stop()
{
}
public void destroy()
{
}
public void run ()
{
Thread.currentThread().setPriority(Thread.MIN_PRIO RITY);
while (true)
{
x_pos ++;
repaint();
try
{
Thread.sleep (20);
}
catch (InterruptedException ex)
{
}
Thread.currentThread().setPriority(Thread.MAX_PRIO RITY);
}
}
public void paint (Graphics g)
{
g.setColor (Color.red);
g.fillOval (x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
}
}
how can i do to make the animation(a moving ball) which is in an applet to become in a JFrame?
thanks for all serious answers :)


LinkBack URL
About LinkBacks






Reply With Quote