On beginning one Ball move from Left to Right, & Second Ball move from Top to Bottom. When You Increase or Decrease The Size of Applet Window the Ball will move Automatically. Any feedback, comments would be greatly appreciated. Please vote for me if you download the code for use.
/* Instruction :- When You Increase or Decrease The Size of
Applet Window the Ball will move Automatically
*/
import java.util.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
//
public class Arc extends Applet implements Runnable
{
Random r = new Random();
int x = 10, y = 10,sang1 = 0, sang2 = 0, he = 500 , wi = 500;
public void init()
{
Thread t = new Thread(this);
t.start();
}
public void run()
{
while(true)
{
try
{
repaint();
Thread.sleep(100);
if( x < wi - 100)
x += 5;
if( y < he - 100)
y += 5;
if( x > wi - 100)
x = wi - 100;
if( y > he - 100)
y = he - 100;
sang1 += 10;
sang2 += 10;
}
catch(Exception e)
{ }
}
}
public void paint(Graphics g)
{
Dimension d = getSize();
he = d.height;
wi = d.width;
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(x,20,100,100,sang1,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(x,20,100,100,sang1 + 90,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(x,20,100,100,sang1 + 180,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(x,20,100,100,sang1 + 270,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(10, y, 100, 100, sang2 ,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(10,y,100,100, sang2 + 90,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(10,y,100,100,sang2 + 180,90);
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.fillArc(10,y,100,100,sang2 + 270,90);
}
}
Best Projects
Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)
Archives
-
▼
2008
(101)
-
▼
June
(32)
- EAR Utility to Compare two EAR files
- J2EE recover(Email Recoverd password)
- Servlet Application
- A CLASS SHOWS HOW
- Back&Fore ground color changer
- Magnifier (VERY NICE)JAR
- Die Roller
- DCSoft DOS Casino
- Card Base Classes
- A Civilisation Game
- Javascript Command Interpreter
- Parellel Port Viewer
- Swing Code to Maintain CD Database
- A Pong Game
- A Basic Game
- Bomber Man
- Logo using Runnable Interface
- Led Digital Clock
- Server Insertion to DB
- File to Array Convertor (JAR file)
- Java Servlet & JDBC Code for Web Development
- Animated Movable Ball
- Beat it Game
- Guessing Game
- Applet game Template.
- SMTP
- Pizza Hut
- Texteditor
- Virtual Network Computing
- GUI For RDBMS
- Calculator
- Smart Mail(Big project)
-
▼
June
(32)
No comments:
Post a Comment