Share on Google+Share on Google+

1 Answer(s)      8 years ago
Posted in : Java Beginners


View Answers

August 24, 2008 at 8:25 PM

I used ur code which is as below but i did not got any error and applet got initilized:

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

public class AppletSleep1 extends Applet implements Runnable {
Thread thread = null;
final static int width = 400;
final static int height = 300;
Image image;
Graphics graphics;
// bouncing lines member variables
int[] x1;
int[] y1;
int[] x2;
int[] y2;
int dx1 = 2 + (int)( 3 * Math.random());
int dy1 = 2 + (int)( 3 * Math.random());
int dx2 = 2 + (int)( 3 * Math.random());
int dy2 = 2 + (int)( 3 * Math.random());
static int first = 0;
final static int LINES = 50;
public void init() {

// create arrays to hold the line coordinates
x1 = new int[LINES];
y1 = new int[LINES];
x2 = new int[LINES];
y2 = new int[LINES];

// initialise the first line
x1[0] = (int)( WIDTH * Math.random() );
y1[0] = (int)( HEIGHT * Math.random() );
x2[0] = (int)( WIDTH * Math.random() );
y2[0] = (int)( HEIGHT * Math.random() );

// initialise all the other lines
for ( int i = 1; i < LINES; i++ ) {
x1[i] = x1[0];
y1[i] = y1[0];
x2[i] = x2[0];
y2[i] = y2[0];
image = createImage(width, height);
graphics = image.getGraphics();
public void start(){

// user visits the page, create a new thread
if(thread == null){
thread = new Thread( this );
public void stop() {
// user leaves the page, stop the thread
if(thread != null && thread.isAlive())
thread = null;
public void run() {
while (thread != null) {
try {
catch(InterruptedException e ){
public void paint(Graphics g) {

public void update(Graphics g) {
// clear the background to white
graphics.setColor( Color.white );
graphics.fillRect( 0, 0, width, height );

// draw the lines
graphics.setColor( );
int line = first;
for ( int i = 0; i < LINES; i++ ) {
graphics.drawLine( x1[line], y1[line], x2[line], y2[line] );
if ( line == LINES ) line = 0;
line = first;
if ( first < 0 ) first = LINES - 1;
x1[first] = x1[line];
y1[first] = y1[line];
x2[first] = x2[line];
y2[first] = y2[line];

// copy buffer to screen
g.drawImage( image, 0, 0, this );

Related Tutorials/Questions & Answers:
MISTAKES CORRECTION  Dear Sir, As you Advised, without compiling, I run the programee with the undermentioned HTML codes in Internet.... Please correct my mistakes and help me please. Thanking you
MISTAKES CORRECTION   Dear Sir, The under mentioned Java Sleep programe was received through your favor. But when I compiled..., this ); } } Kindly help me to correct my mistakes
Top 10 SEO Mistakes,Common Mistakes in Search Engine Optimization,Search Engine Marketing Mistakes
Search Engine Mistakes - Search Engine Optimization Mistakes... in the search engines are due to very simple mistakes in designing the web site... techniques to improve your ranking in the Search Engines. Link Exchange Mistakes You
Mistakes To Be Avoided While Writing Articles
Mistakes To Be Avoided While Writing Articles   ... your website. 7 mistakes which must be avoided in order to make your article.... Avoid these 7 mistakes for increasing your article's success probabilities
10 Common Web Design Mistakes
10 Common Web Design Mistakes Designing a website is the most crucial part... discussion on top 10 common web design mistakes we must understand the effectiveness of good design attributes and on the opposite side the mistakes that make
Top 10 Web Design Mistakes
Blaming the web design mistakes is a common behavior when a website faces... aspects is lost. There are many philosophies on classifying the web design mistakes but some mistakes are very common to have most disastrous effects
10 SEO Mistakes Most People Do
10 SEO Mistakes Most People Do Your excellence in making your SEO campaign... to how you avoid certain SEO mistakes most people do. These mistakes are sometimes... behind the failure of SEO campaign. Some of these mistakes are deliberate
GPS Map       The GPS Map 76 The GPSMAP- 76 is designed to provide precise GPS positioning using correction data obtained from the Wide Area Augmentation System
Common Interview Questions Page - 7
marks rather you may mention that if you had avoided certain mistakes, perhaps you
rEPLY - Java Beginners
rEPLY  hi, This is session code i am calling admin_home1.jsp then data will be not displaying its urgent requirement please send me correction Thanks   Hi friend, To display the session
How to design a background, design a background, a background
. Lens correction: Go to Filter menu > Distort >Apply Lens correction
Advance Search in Servlet
. the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
. the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
. the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
. the string typed in is "With regards to the correction in pay" later on in the search
checking the data
typed in is "With regards to the correction in pay" later on in the search module
correction: System.out.println("No of items:"+tooa1Item); After the modification, if you
Molu - The Search Spider
with Related Term Suggestion and Spelling Correction Tool. Read full Description
SCJP Module-3 Question-7
of the inner class. 4. no need of correction. Answer :   Explanation : An inner
. Do correction: System.out.println("No of items:"+tooa1Item); After
of all your for statement is not correct. Do correction: for(double index=0.1;index
named count. 2)Do correction: System.out.println("No of items:"+tooa1Item); After
SCJP Module-9 Question-27
)". 2. No need of the correction. 3. By changing the value of the method
Techniques to Improve GPS Accuracy
correction to their readings. This civilian system works parallel... the required correction. The correction message is then relayed to GPS receivers... Augmentation System Local Area Augmentation System or LAAS uses similar correction
Dont Post Inner Adv and Adult Content Adv .
Inners Adv and Adult Content Adv . I hope you will not do the mistakes again
SCJP Module-12 Question-8
of correction 2. By adding "static float flt = 0;" before line 1 3
SCJP Module-9 Question-26
? 1. No need of correction. 2. By replacing  " reverse(mylist)"
SCJP Module-6 Question-17
of correction 2. By changing "Exception" class to "Error"
SCJP Module-6 Question-19
. No need of correction 2. By adding 'static' to class at line number 1
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null