当前位置: 技术问答>java相关
我在网页上放了一个JAVA按钮控制背景音乐,在我的机子上运行正常,可在别的机子却产生错误,源代码如下。。。(急,在线等待)
来源: 互联网 发布时间:2015-05-12
本文导语: // Source File Name: bgsound.java import java.applet.Applet; import java.applet.AppletContext; import java.awt.*; import java.net.MalformedURLException; import java.net.URL; public class bgsound extends Applet { public void init() { ...
// Source File Name: bgsound.java
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
public class bgsound extends Applet
{
public void init()
{
img1 = getImage(getDocumentBase(), getParameter("img1"));
img2 = getImage(getDocumentBase(), getParameter("img2"));
framename = getParameter("framename");
documentname1 = getParameter("documentname1");
documentname2 = getParameter("documentname2");
soundopen = getParameter("soundopen");
soundclose = getParameter("soundclose");
img = img1;
try
{
url1 = new URL(getDocumentBase(), documentname1);
url2 = new URL(getDocumentBase(), documentname2);
}
catch(MalformedURLException _ex) { }
c = true;
url = url1;
status = soundopen;
}
public void start()
{
}
public void paint(Graphics g)
{
update(g);
}
public void stop()
{
}
public void destory()
{
}
public void run()
{
}
public void update(Graphics g)
{
g.drawImage(img, 0, 0, this);
}
public boolean mouseDown(Event event, int i, int j)
{
if(c)
{
img = img2;
url = url2;
status = soundopen;
c = false;
} else
{
img = img1;
url = url1;
status = soundclose;
c = true;
}
getAppletContext().showDocument(url, framename);
repaint();
showStatus(status);
return true;
}
public boolean mouseEnter(Event event, int i, int j)
{
if(c)
showStatus(soundclose);
else
showStatus(soundopen);
return true;
}
public boolean mouseExit(Event event, int i, int j)
{
return true;
}
public bgsound()
{
}
boolean c;
Image img;
Image img1;
Image img2;
String framename;
String documentname1;
String documentname2;
String soundopen;
String soundclose;
String status;
URL url;
URL url1;
URL url2;
}
在别的机子上显示错误为:exception:com.ms.security.exceptionEx[bgsound.init]:cannot access file//site/public/background.gif
此时按钮为灰色不可用
在网页内的调用为:
请高手帮助!
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
public class bgsound extends Applet
{
public void init()
{
img1 = getImage(getDocumentBase(), getParameter("img1"));
img2 = getImage(getDocumentBase(), getParameter("img2"));
framename = getParameter("framename");
documentname1 = getParameter("documentname1");
documentname2 = getParameter("documentname2");
soundopen = getParameter("soundopen");
soundclose = getParameter("soundclose");
img = img1;
try
{
url1 = new URL(getDocumentBase(), documentname1);
url2 = new URL(getDocumentBase(), documentname2);
}
catch(MalformedURLException _ex) { }
c = true;
url = url1;
status = soundopen;
}
public void start()
{
}
public void paint(Graphics g)
{
update(g);
}
public void stop()
{
}
public void destory()
{
}
public void run()
{
}
public void update(Graphics g)
{
g.drawImage(img, 0, 0, this);
}
public boolean mouseDown(Event event, int i, int j)
{
if(c)
{
img = img2;
url = url2;
status = soundopen;
c = false;
} else
{
img = img1;
url = url1;
status = soundclose;
c = true;
}
getAppletContext().showDocument(url, framename);
repaint();
showStatus(status);
return true;
}
public boolean mouseEnter(Event event, int i, int j)
{
if(c)
showStatus(soundclose);
else
showStatus(soundopen);
return true;
}
public boolean mouseExit(Event event, int i, int j)
{
return true;
}
public bgsound()
{
}
boolean c;
Image img;
Image img1;
Image img2;
String framename;
String documentname1;
String documentname2;
String soundopen;
String soundclose;
String status;
URL url;
URL url1;
URL url2;
}
在别的机子上显示错误为:exception:com.ms.security.exceptionEx[bgsound.init]:cannot access file//site/public/background.gif
此时按钮为灰色不可用
在网页内的调用为:
请高手帮助!
|
看来是权限问题