applet working in applet viewer, not browser
i made several silly little applets that works fine in a applet viewer on my ide, but when i tried to load it on a browser, i would get weird results.
Code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Eyes2 extends JApplet{
private int x2 = 198;
private int y2 = 199;
private int width2 = 15;
private int height2 = 15;
public void init(){
getContentPane().setBackground(Color.black);
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.white);
g.fillOval(x2, y2, width2, height2);
addMouseListener(new MyMouseListener());
addMouseMotionListener(new MyMouseMotionListener());
}
private class MyMouseListener
implements MouseListener
{
public void mousePressed(MouseEvent e)
{
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
x2 = 198;
y2 = 199;
repaint();
}
public void mouseExited(MouseEvent e)
{
x2 = 198;
y2 = 199;
repaint();
}
}
private class MyMouseMotionListener
implements MouseMotionListener
{
public void mouseDragged(MouseEvent e)
{
}
public void mouseMoved(MouseEvent e)
{
x2 = e.getX();
y2 = e.getY();
repaint();
}
}
}
all this applet does is display a circle that would follow your mouse everywhere. again, this works perfect on the applet viewer, but on a browser, the circle doesn't move at all.
i've also made other applets, and one of them would appear on the site half of the time, and the other half, it would give me a blank page. can someone tell me is there something fundamentally wrong with my code?