Animation in Applets
Hello sir,
I have a code for you .this code is for moving a plane in an applet,but unfortunatly
this code is not working .can you kindly help me out to solve this problem.
code:
import java.applet.*;
import java.awt.*;
import java.net.*;
/*<applet code="Moveplane.class" height=600 width=800>
</applet>
*/
public class Moveplane extends Applet
{
public void paint(Graphics g)
{
Font f=new Font("Arial",Font.BOLD,30);
g.setFont(f);
g.setColor(Color.green);
g.drawString("Telangana AirLines",300,35);
try
{
Image i1=getImage(getDocumentBase(),"a1.gif");
g.drawImage(i1,50,50,null);
Thread.sleep(100);
}
catch(Exception e){}
for(int s1=7,s2=70; s1<6100||s2<3000;)
{
if(s1<610)
s1=s1+9;
if(s2<300)
s2=s1+20;
try
{
Thread.sleep(100);
}
catch(Exception e){}
}
}
}
View Answers
March 25, 2010 at 5:40 PM
Hi Friend,
Try the following code:
import java.io.*;
import java.net.*;
import java.awt.*;
import java.util.*;
import java.applet.*;
import javax.imageio.*;
import java.awt.event.*;
import java.awt.image.*;
public class Moveplane extends Applet implements Runnable{
Vector <Move> vector;
java.util.List<BufferedImage> images = new ArrayList<BufferedImage>();
BufferedImage buffImage;
Thread thread;
boolean animating = false;
public void init() {
loadImages();
vector = new Vector<Move>();
Move kw = new Move(100, 100, 10, 1);
vector.addElement(kw);
resize(500, 500);
}
public void start() {
if(!animating) {
animating = true;
thread = new Thread(this);
thread.start();
}
}
public void update(Graphics g) {
if(buffImage == null){
int w = getWidth();
int h = getHeight();
int type = BufferedImage.TYPE_INT_RGB;
buffImage = new BufferedImage(w, h, type);
Graphics2D g2 = buffImage.createGraphics();
g2.setPaint(getBackground());
g2.fillRect(0,0,w,h);
g2.dispose();
}
g.drawImage(buffImage, 0, 0, this);
}
public void run() {
while (animating) {
repaint();
try {
thread.sleep(10);
}
catch (Exception e){ }
Graphics2D g2 = buffImage.createGraphics();
g2.setPaint(getBackground());
g2.fillRect(0,0,buffImage.getWidth(), buffImage.getHeight());
for(int i = 0; i < vector.size(); i++) {
Move kw = vector.elementAt(i);
kw.advance();
BufferedImage image = images.get(i);
g2.drawImage(images.get(i), kw.x, kw.y, this);
}
g2.dispose();
}
}
private void loadImages() {
String[] ids = { "image2.png" };
for(int j = 0; j < ids.length; j++) {
try {
URL url = getClass().getResource(ids[j]);
images.add(ImageIO.read(url));
}
catch(IOException e) { }
}
}
}
class Move{
int x;
int y;
int d;
int vx;
Move(int X, int Y, int D, int VX) {
x = X;
y = Y;
d = D;
vx = VX;
}
public void advance() {
x += vx;
if(x >= 500)
vx=-Math.abs(vx);
if(x <= 0)
vx=Math.abs(vx);
}
}
Thanks
Related Tutorials/Questions & Answers:
Animation in Applets - AppletAnimation in Applets Hello sir,
I have a code for you .this code is for moving a plane in an applet,but unfortunatly
this code is not working .can you kindly help me out to solve this problem.
code:
import
Applets?Applets?
applets are using now a days
Please visit the following link:
Applet Tutorials
Advertisements
APPLETS - SecurityAPPLETS In java
applets sun.misc is not working can any body help me for the alternate solution.
while using
new sun.misc.BASE64Encoder().encode(enc);
i got runtime error...
java.security.AccessControlException
Applications and Applets
Applications and
Applets
Now a days, Java is widely used for applications and
applets. The code... the user's browser.
Applets can be very useful, user friendly programs
or can
ModuleNotFoundError: No module named 'animation'ModuleNotFoundError: No module named '
animation' Hi,
My Python... '
animation'
How to remove the ModuleNotFoundError: No module named '
animation' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'animation'ModuleNotFoundError: No module named '
animation' Hi,
My Python... '
animation'
How to remove the ModuleNotFoundError: No module named '
animation' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'animation'ModuleNotFoundError: No module named '
animation' Hi,
My Python... '
animation'
How to remove the ModuleNotFoundError: No module named '
animation' error?
Thanks
Hi,
In your python environment you
Free Java Applets
Free Java
Applets
There are many free java
applets available on the web that you can use
in your website. These
applets includes menu, clock, slide show, image
animation Applications and Applets
Applications and
Applets
Now a days, Java is widely used for applications and
applets. The code... the user's browser.
Applets can be very useful, user friendly programs
or can
Bindows animation library
Bindows
animation library
Bindows
animation library enables adding animations to Bindows components -
thus creating visual effects like pulsating buttons, fade-ins, fade-outs
animation in applet - Appletanimation in applet Hello sir,
your code is ok
but what happend to this code can you modify this an tell me problem please
code:
import java.applet.*;
import java.awt.*;
import java.net.*;
/*
*/
public class
Example code of jQuery animation
Example code of jQuery
animation
Example code of jQuery
animation
The jQuery is very powerful framework. It provides a many
animation
effects that can
Careers in AnimationCareers in
Animation
You have all the praise for the characters like Mickey..., the people who can create magic with the visual effects.
Animation is one... combination of text, images, graphics,
animation and audio.
Who can become
Animation in Java Applet
Applet is a java class that runs inside the internet browser.
It uses Thread along with its methods for
animation.
Applet class implements the Runnable interface for
animation
program.
Example of
Animation in Java program
Programming using applets and oracle - AppletProgramming using
applets and oracle Develop an Online Examination software in java using
applets as front end and oracle as back end. Software should handle at least ten users at a time. There are Multiple Choice questions
Applets in JavaApplet is a Java program embedded within HTML pages. Java
applets
is compatible with almost all the web browsers like Mozilla Firefox, Google
Chrome, Internet explorer, Netscape navigator and others that are java enabled.
Applets How to create Animation
How to create
Animation
This section illustrates you how to create
Animation. We.... The method fillRect()
fills the rectangle with the colors showing
animation How to create Animation
How to create
Animation
This section illustrates you how to create
Animation. We.... The method fillRect()
fills the rectangle with the colors showing
animation J2ME Frame Animation J2ME Frame
Animation
This application shows to set the Frame
Animation and implement it in the canvas class.
In this example we are creating a frame using Gauge class. When
J2ME Animation using repaint( ) method J2ME
Animation using repaint( ) method
... are going to show you how to create
an Image with
animation. Here we have create... the CommandListner class. We have also used the
predefined Canvas class to show the
animation Role of Java Applets in Web Application Development In this article, we are discussing about the role of Java
Applets in web application development. As we all know that an Applet is a simple Java program, which is written in Java programming language that extends the java.applet.
Line Animation in Java
Line
Animation in Java
In this example we are creating an animated line. The color of line is
changing alternatively.
We use drawLine() to draw a line
J2ME Timer Animation J2ME Timer
Animation
This application illustrates how to use the Timer class and implement
it in the canvas class. In this Tutorial we have given you a good example