Solved

Animation Using Constant Gif Strip

Posted on 1998-09-03
3
255 Views
Last Modified: 2008-03-06
What Is setbounds method in rectangle class ? what is the basic purpose of using it? How do we use threads for moving different graphics object?
0
Comment
Question by:vipin072998
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
diakov earned 50 total points
ID: 1223558
- r.setBounds() reshapes an existing Rectangle r object.
- For animation purposes of animation there some quite good examples. I paste a link. You have to apply some changes in order to customize it properly.
-------
http://java.sun.com/applets/applets/Animator/
0
 

Author Comment

by:vipin072998
ID: 1223559
You have not told me anything regarding threads handling using JAVA. i KNOW HOPW TO CREATE THREADS? But explainf me regarding when we create more than one thread in a single applet then where shall we define the code for different threads?
0
 
LVL 8

Expert Comment

by:diakov
ID: 1223560
You can create many threads the same two ways you create one. Well, then the codes differs a little bit.
If your threads inherit the Thread class, then you can create as many as you want just by calling the new operator, then object.start() and there they go.
If you implement the Runnable interface in a class (let say the applet itself) to make it have different thread then you have to do the following:
- in the constructor: c1 = new Thread(this); //where 'this' is a reference to the object (the applet) that implements the runnable interface and c1 is a variable where you store reference to the thread object in case you need it later. If you create many Threads you have to store in a vector or a hash table or several variables. The you call c1.start() in order to start the Thread execution. This means the run() method is called for the object implementing the Runnable (remember, you passed the this reference as an argument to the constructor of the thread) This run() will be called in a separate thread as many times as threads you got.
- Then in the run() method you do the following:
public void run()
{
  Thread temp = java.lang.Thread.currentThread();
  if (temp == c1)
  {
    //do the stuff thread c1 has to do
  }
  else if (temp == c2)
  {
    //do the stuff thread c2 has to do
  }
.
}
Cheers.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question