Im writing a small applet and I'm having problems with the 2 gif images. I can get the applet to run with images using the appletviewer. However, when I try to use the web browser I can only get it to work if I take out all imaging before compilation. I am using a jar file (BoneJarFile.jar) which consists of the Bone.class file and two gif's. Here is the HTML code:
<HTML>
<HEAD>
<TITLE> BONE THUGS </TITLE>
</HEAD>
<CENTER>
<H1> THE GREATEST </H1>
<P>
<APPLET CODE = Bone.class ARCHIVE = BoneJarFile.jar width = 400 height = 360>
</APPLET>
</CENTER>
</BODY>
</HTML>
Here's a clip of the source, its short:
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
public class Bone extends JApplet implements Runnable{
Image bone = new javax.swing.ImageIcon("boneThugs.gif".getImage();
Image boneName = new javax.swing.ImageIcon("bone.gif".getImage();
String yo = "THE GREATEST RAP GROUP OF ALL TIME";
Thread t;
public void init(){
setBackground(new Color(10,130,115));
t = new Thread(this, "Bone sequence"
}
public void start(){
}
public void run(){}
public void paint(Graphics g){
Graphics2D g2 = (Graphics2D)g;
try{
g2.setColor(new Color(10,130,115));
g2.fillRect(0,0,400,360);
t.sleep(1000);
g2.setColor(Color.blue);
g2.drawString(yo, 75, 25);
t.sleep(1000);
//g2.drawImage(bone,95,45,this);
t.sleep(1000);
//g2.drawImage(boneName,120,265,this);
t.sleep(1000);
}catch(InterruptedException e){}
repaint();
}
}
I get a security error when I try to initialize the first image; I know applets cant access client machines, but this is coming from the JAR file, so it should be okay? But its not, help!
<HTML>
<HEAD>
<TITLE> BONE THUGS </TITLE>
</HEAD>
<CENTER>
<H1> THE GREATEST </H1>
<P>
<APPLET CODE = Bone.class ARCHIVE = BoneJarFile.jar width = 400 height = 360>
</APPLET>
</CENTER>
</BODY>
</HTML>
Here's a clip of the source, its short:
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
public class Bone extends JApplet implements Runnable{
Image bone = new javax.swing.ImageIcon("boneThugs.gif".getImage();
Image boneName = new javax.swing.ImageIcon("bone.gif".getImage();
String yo = "THE GREATEST RAP GROUP OF ALL TIME";
Thread t;
public void init(){
setBackground(new Color(10,130,115));
t = new Thread(this, "Bone sequence"
}
public void start(){
}
public void run(){}
public void paint(Graphics g){
Graphics2D g2 = (Graphics2D)g;
try{
g2.setColor(new Color(10,130,115));
g2.fillRect(0,0,400,360);
t.sleep(1000);
g2.setColor(Color.blue);
g2.drawString(yo, 75, 25);
t.sleep(1000);
//g2.drawImage(bone,95,45,this);
t.sleep(1000);
//g2.drawImage(boneName,120,265,this);
t.sleep(1000);
}catch(InterruptedException e){}
repaint();
}
}
I get a security error when I try to initialize the first image; I know applets cant access client machines, but this is coming from the JAR file, so it should be okay? But its not, help!