Results 1 to 2 of 2

Thread: bouncing ball using JApplet

  1. #1
    kr04t
    Guest


    bouncing ball using JApplet

    [src]
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;

    public class test extends JApplet implements Runnable
    {
    public void init(){}
    public void paint(Graphics g)
    {
    int dx= -1,dy= -1;
    int x=0,y=0,o=0;
    Color c[]={Color.red,Color.green,Color.blue};
    Color l=Color.red;
    Random r=new Random();
    for (int i=0;;i++)
    {
    try{
    if (dx<0||dy<0)
    {
    if (x<0||y<0)
    {
    dx=2;
    dy=1;
    l=c[o%3];
    o++;
    }
    }
    else if (dx>0||dy>0)
    {
    if (x>490||y>290)
    {
    dx= -2;
    dy= -1;
    l=c[o%3];
    o++;
    }
    }
    x+=dx;
    y+=dy;
    g.setColor(l);
    g.fillOval(x,y,10,10);
    Thread.sleep(10);}
    catch(Exception e){}
    g.setColor(Color.white);
    g.fillRect(0,0,500,300);
    }
    }
    public void run()
    {
    try{Thread.sleep(10);}
    catch(Exception e){}
    repaint();
    }
    }[/src]

  2. #2
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: bouncing ball using JApplet

    Very interesting , it would be useful for every people.

Similar Threads

  1. Nine-ball attack splits security researchers
    By newsbot in forum World Hacking/Security News
    Replies: 0
    Last Post: 23-06-2009, 08:28 PM
  2. Crystal Ball Professional 7.2.2
    By PokemonMu in forum Window Application
    Replies: 0
    Last Post: 26-11-2006, 06:12 PM
  3. assign 105 ball
    By Anonymous in forum Java
    Replies: 2
    Last Post: 03-12-2004, 10:45 AM
  4. Replies: 0
    Last Post: 15-12-2003, 05:58 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •