当前位置: 技术问答>java相关
发布Applet不能添加图片,。。。。help
来源: 互联网 发布时间:2015-08-23
本文导语: 代码如下;import javax.swing.*; import java.awt.*; public class applet extends JApplet { JPanel panel; GridBagLayout gl; GridBagConstraints gbc; JLabel labelname; JButton button1; JButton button2; Icon ic1; //URL url; public void init() { //create pa...
代码如下;import javax.swing.*;
import java.awt.*;
public class applet extends JApplet
{
JPanel panel;
GridBagLayout gl;
GridBagConstraints gbc;
JLabel labelname;
JButton button1;
JButton button2;
Icon ic1;
//URL url;
public void init()
{
//create panel
panel=new JPanel();
gl=new GridBagLayout();
gbc=new GridBagConstraints();
panel.setLayout(gl);
getContentPane().add(panel);
//create label
labelname=new JLabel("欢迎来到购物城");
//url=new URL(/tech-qa-java/calculator.gif);
ic1=new ImageIcon("calculator.gif");
//create button
button1=new JButton("您确定要购买",ic1);
button2=new JButton("保留态度");
gbc.fill=GridBagConstraints.BOTH;
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=0;
gbc.gridy=5;
gl.setConstraints(labelname,gbc);
panel.add(labelname);
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=0;
gbc.gridy=15;
gl.setConstraints(button1,gbc);
panel.add(button1);
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=10;
gbc.gridy=15;
gl.setConstraints(button2,gbc);
panel.add(button2);
}
}
html文件:
运行applet出现Exception:java.security.accesscontrol Exception:
access denide(java.io.filepermission calculator.gif read)
并说小应用程序applet notiniter
是什么原因,如何解决,不妨赐教.........
import java.awt.*;
public class applet extends JApplet
{
JPanel panel;
GridBagLayout gl;
GridBagConstraints gbc;
JLabel labelname;
JButton button1;
JButton button2;
Icon ic1;
//URL url;
public void init()
{
//create panel
panel=new JPanel();
gl=new GridBagLayout();
gbc=new GridBagConstraints();
panel.setLayout(gl);
getContentPane().add(panel);
//create label
labelname=new JLabel("欢迎来到购物城");
//url=new URL(/tech-qa-java/calculator.gif);
ic1=new ImageIcon("calculator.gif");
//create button
button1=new JButton("您确定要购买",ic1);
button2=new JButton("保留态度");
gbc.fill=GridBagConstraints.BOTH;
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=0;
gbc.gridy=5;
gl.setConstraints(labelname,gbc);
panel.add(labelname);
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=0;
gbc.gridy=15;
gl.setConstraints(button1,gbc);
panel.add(button1);
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.gridx=10;
gbc.gridy=15;
gl.setConstraints(button2,gbc);
panel.add(button2);
}
}
html文件:
运行applet出现Exception:java.security.accesscontrol Exception:
access denide(java.io.filepermission calculator.gif read)
并说小应用程序applet notiniter
是什么原因,如何解决,不妨赐教.........
|
需要添加认证!
假定你的类名为monitor.java
1:jar cvf monitor.jar *.class
2:keytool -genkey -keystore monitor.keystore –alias monitor
3:jarsigner -keystore monitor.keystore monitor.jar monitor
4:keytool -export -keystore monitor.keystore -alias monitor -file monitor.cer
然后把所有的资源文件和类文件、原文件加入monitor.jar中
html调用:
"
"
假定你的类名为monitor.java
1:jar cvf monitor.jar *.class
2:keytool -genkey -keystore monitor.keystore –alias monitor
3:jarsigner -keystore monitor.keystore monitor.jar monitor
4:keytool -export -keystore monitor.keystore -alias monitor -file monitor.cer
然后把所有的资源文件和类文件、原文件加入monitor.jar中
html调用:
"
"