Solved

Animation Using Constant Gif Strip

Posted on 1998-09-03
3
246 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

774 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