Solved

Animation Using Constant Gif Strip

Posted on 1998-09-03
3
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

730 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