hello friend i made a small racket game using three classes one is graphic for paint perposes, second is test for performing functions and actionmlisteners and the 3rd is applet which is extended by JApplet my programme run fine on applet viewer but not on browser ..
here the classes are
graphic.......................
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.awt.geom.*;

class graphic extends JPanel
{
int xcod;
int ycod;
int ballx;
int bally;
int width;
public graphic()
{
setBackground(Color.ORANGE);
xcod=290;
ycod=0;
ballx=5;
bally=0;

}
public void paintComponent(Graphics g)
{


super.paintComponent(g);
BufferedImage image=null;

Graphics2D object =(Graphics2D) g;
object.setColor(Color.RED);
object.fillOval(ballx, bally, 20, 20);


try {
image=ImageIO.read(new File("racket.gif"));
}
catch (IOException e)
{

System.out.print(e);
}
//image.
object.drawImage( image,xcod,ycod,null);




}
public void setX(int x)
{
xcod=x;
}
public void setY(int y)
{
ycod=y;
}
}

..................................
test class..............

import javax.swing.*;

import java.awt.event.*;
import java.awt.*;
import sun.audio.*;

import java.io.*;

import javazoom.jl.player.Player;
import java.applet.*;

public class test extends JPanel implements MouseMotionListener,ActionListener,KeyEventDispatc her
{
JFrame frame;
graphic graphics;
Timer t=null;
int x=5;
int y=3;
AudioClip sound1;
AudioClip sound2;
Player obj;
AudioPlayer player;
public void playHit()
{
try
{
FileInputStream input =new FileInputStream("hit.mp3");
obj=new Player(input);

obj.play();





}
catch(Exception e)
{
e.printStackTrace();

}


}

test()
{



graphics=new graphic();
setLayout(new BorderLayout());

add(graphics,BorderLayout.CENTER);
//setSize(400,400);

setVisible(true);
addMouseMotionListener(this);
KeyboardFocusManager.getCurrentKeyboardFocusManage r().addKeyEventDispatcher(this);



t=new Timer(30,this);
t.start();

}
public void actionPerformed(ActionEvent event)
{


if(getWidth()-40==graphics.ballx)
{

x=-5;

}
else if(graphics.ballx==0)
{

x=5;
}
else if(getHeight()-40==graphics.bally)
{


y=-3;
}
else if(graphics.bally==0)
{

y=3;

}
if((graphics.ballx>graphics.xcod+34 && graphics.ballx< graphics.xcod+85) && (graphics.bally>graphics.ycod && graphics.bally<graphics.ycod+60))
{

if(x>0 && y>0)
{
playHit();

x=-5;
y=-3;



graphics.setX(graphics.xcod+10);
graphics.setY(graphics.ycod+10);




}
else if(x>0&& y<0)
{
playHit();

x=-5;
y=-3;

graphics.setX(graphics.xcod+10);
graphics.setY(graphics.ycod+10);


}
else if(x<0 && y>0)
{
playHit();


x=-5;
y=-3;

graphics.setX(graphics.xcod+10);
graphics.setY(graphics.ycod+10);



}
else if(x<0 && y<0)
{
playHit();



x=-5;
y=3;

graphics.setX(graphics.xcod+10);
graphics.setY(graphics.ycod+10);

}


}
graphics.ballx=graphics.ballx+x;
graphics.bally=graphics.bally+y;
graphics.repaint();







}
public void mouseDragged(MouseEvent e)
{




}
public void mouseMoved(MouseEvent ev)
{
if(ev.getX()<=300 && ev.getY()<=getHeight()-80)
{


graphics.setX(ev.getX());
graphics.setY( ev.getY() );

graphics.repaint();
}

}



public boolean dispatchKeyEvent(KeyEvent e)
{

if(e.getKeyCode()==KeyEvent.VK_LEFT)
{
if(graphics.xcod>0)
{


graphics.setX(graphics.xcod-5);

graphics.repaint();
}
}
else if(e.getKeyCode()==KeyEvent.VK_RIGHT)
{
if(graphics.xcod<getWidth()-100)
{


graphics.setX(graphics.xcod+5);
graphics.repaint();
}
}
else if(e.getKeyCode()==KeyEvent.VK_UP)
{
if(graphics.ycod>0)
{

graphics.setY(graphics.ycod-5);
graphics.repaint();
}
}
else if(e.getKeyCode()==KeyEvent.VK_DOWN)
{
if(graphics.ycod<getHeight()-100)
{



graphics.setY(graphics.ycod+5);
graphics.repaint();
}
}
return true;

}





public void keyReleased(KeyEvent arg1)
{


}

public void keyTyped(KeyEvent arg2)
{


}
}
.......................................
applet class...................

import java.applet.AudioClip;
import java.awt.*;

import javax.swing.*;
public class applet extends JApplet
{
AudioClip sound;
public void init()
{
sound=getAudioClip(getDocumentBase(),"music.wav");
sound.loop();
test obj=new test();

setSize(400,400);

add(obj,BorderLayout.CENTER);

}
}
...................