Add to Favorites    Make Home Page 3972 Online  
 Language Categories  
 Our Services  

Home » Java Home » Beginners / Lab Assignments Home » A Ball Moving round the window.

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title A Ball Moving round the window.
Author kiran
Author Email kiran_bisn [at] yahoo.com
Description
Category Java » Beginners / Lab Assignments
Hits 370934
Code Select and Copy the Code
:/* <applet code="screencircle2" width=300 height=300> </applet> */ import java.applet.*; import java.awt.*; public class screencircle2 extends Applet implements Runnable { Thread t; int i,j,k,l,flag=0,m,x1,y1,x2,y2,m1,x3,y3,m2,m3; Color bg; public void init() { } public void start() { t=new Thread(this,"a"); t.start(); } public void run() { paint1(); } public void paint1() { Graphics g=getGraphics(); try { for(i=0;i<260;i++) { for(j=130;j<=260;j++) { g.setColor(Color.red); g.fillOval(i,j,40,40); Thread.sleep(50); i=i+5; j=j+5; paint2(); if(j>=260) { k=i; l=j; paint3(); break; } } } } catch(InterruptedException s) { //ShowStatus("error"); } } public void paint3() { setBackground(Color.black); Graphics h=getGraphics(); try { for(x1=k;x1<=260;x1++) { for(y1=j;y1>1;y1--) { h.setColor(Color.red); h.fillOval(x1,y1,40,40); Thread.sleep(50); x1=x1+6; y1=y1-4; paint2(); if(x1>=260) { m=x1; m1=y1; paint4(); } } } } catch(InterruptedException s1) { //ShowStatus("error"); } } public void paint4() { Graphics h1=getGraphics(); try { for(x2=m;x2>=40;x2--) { for(y2=m1;y2>=1;y1--) { h1.setColor(Color.red); h1.fillOval(x2,y2,40,40); Thread.sleep(50); x2=x2-5; y2=y2-6; paint2(); if(y2<=1) { m2=x2; m3=y2; paint5(); } } } } catch(InterruptedException s1) { //ShowStatus("error"); } } public void paint5() { setBackground(Color.black); Graphics h2=getGraphics(); try { for(x3=m2;x3>=1;x3--) { for(y3=m3;y3<260;y3++) { h2.setColor(Color.red); h2.fillOval(x3,y3,40,40); Thread.sleep(50); x3=x3-6; y3=y3+4; paint2(); if(x3<=1) { m=x1; m1=y1; paint1(); } } } } catch(InterruptedException s1) { //ShowStatus("error"); } } public void paint2() { Graphics d=getGraphics(); d.setColor(Color.white); d.fillRect(0,0,300,300); setBackground(Color.black); } }

Related Source Codes

Script Name Author
Sending mail Using JavaMail to Yahoo and Gmail accounts sai prasad
Simple Program in Java to Implement Multithreading Satish.K
Simple Calculator in Java Using Remote Method Invocation Satish.K
Guest Book Application Using Servlets Satish.K
String Manipulation Using Stringification Satish.K
String Manipulation Using Stringification Satish.K
Moving Ball Application Using Java Beans Satish.K
Rapid Roll game subrahmanyeswararao
student mgm arpan
Sourav Datta
Download Manager Sagar
Address Book in Java Rahul Chouhan
address book using java database connectivity(jdbc-msaccess) shekhar bansal
sun Steganography B.Rajavel
Connecting Java with MS-Access - Inserting data in Aseem

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=577


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review