当前位置: 技术问答>java相关
问题多多,高手快来,现在我只能给25分
来源: 互联网 发布时间:2015-01-08
本文导语: 在jdk的appletviewer WelcomeApplet.html是正常的 但: (1)双击WelcomeApplet.html则:This applet is from the book Core Java by Cay Horstmann and Gary cornell, published by Sun Microsystems Press 状态栏:access denied(java.lang.RuntimePermission modifyTreadGr...
在jdk的appletviewer WelcomeApplet.html是正常的
但:
(1)双击WelcomeApplet.html则:This applet is from the book Core Java by Cay Horstmann and Gary cornell, published by Sun Microsystems Press
状态栏:access denied(java.lang.RuntimePermission modifyTreadGroup).
(2)用appletviewer时出现的窗口只是applet程序窗口,不出现html的词句:This applet is from the book Core Java by Cay Horstmann and Gary cornell, published by Sun Microsystems Press,能否让它出现?
WelcomeApplet.html代码如下:
WelcomeApplet
This applet is from the book
Core Java by Cay Horstmann and Gary Cornell,
published by Sun Microsystems Press.
The source.
WelcomeApplet.java代码如下:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class WelcomeApplet extends JApplet
implements ActionListener
{ public void init()
{ Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
JLabel label = new JLabel(getParameter("greeting"),
SwingConstants.CENTER);
label.setFont(new Font("TimesRoman", Font.BOLD, 18));
contentPane.add(label, "Center");
JPanel panel = new JPanel();
cayButton = new JButton("Cay Horstmann");
cayButton.addActionListener(this);
panel.add(cayButton);
garyButton = new JButton("Gary Cornell");
garyButton.addActionListener(this);
panel.add(garyButton);
contentPane.add(panel, "South");
}
public void actionPerformed(ActionEvent evt)
{ Object source = evt.getSource();
String urlName;
if (source == cayButton)
urlName = "http://www.horstmann.com";
else if (source == garyButton)
urlName = "mailto:gary@thecornells.com";
else return;
try
{ URL u = new URL(/tech-qa-java/urlName/index.html);
getAppletContext().showDocument(u);
}
catch(Exception e)
{ showStatus("Error " + e);
}
}
private JButton cayButton;
private JButton garyButton;
}
注:使用jdk1.3.0.2
但:
(1)双击WelcomeApplet.html则:This applet is from the book Core Java by Cay Horstmann and Gary cornell, published by Sun Microsystems Press
状态栏:access denied(java.lang.RuntimePermission modifyTreadGroup).
(2)用appletviewer时出现的窗口只是applet程序窗口,不出现html的词句:This applet is from the book Core Java by Cay Horstmann and Gary cornell, published by Sun Microsystems Press,能否让它出现?
WelcomeApplet.html代码如下:
WelcomeApplet
This applet is from the book
Core Java by Cay Horstmann and Gary Cornell,
published by Sun Microsystems Press.
The source.
WelcomeApplet.java代码如下:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class WelcomeApplet extends JApplet
implements ActionListener
{ public void init()
{ Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
JLabel label = new JLabel(getParameter("greeting"),
SwingConstants.CENTER);
label.setFont(new Font("TimesRoman", Font.BOLD, 18));
contentPane.add(label, "Center");
JPanel panel = new JPanel();
cayButton = new JButton("Cay Horstmann");
cayButton.addActionListener(this);
panel.add(cayButton);
garyButton = new JButton("Gary Cornell");
garyButton.addActionListener(this);
panel.add(garyButton);
contentPane.add(panel, "South");
}
public void actionPerformed(ActionEvent evt)
{ Object source = evt.getSource();
String urlName;
if (source == cayButton)
urlName = "http://www.horstmann.com";
else if (source == garyButton)
urlName = "mailto:gary@thecornells.com";
else return;
try
{ URL u = new URL(/tech-qa-java/urlName/index.html);
getAppletContext().showDocument(u);
}
catch(Exception e)
{ showStatus("Error " + e);
}
}
private JButton cayButton;
private JButton garyButton;
}
注:使用jdk1.3.0.2
|
urlName = "http://www.horstmann.com";
URL u = new URL(/tech-qa-java/urlName/index.html);
getAppletContext().showDocument(u);
你在访问applet所在主机以外的地址,这是applet权限所不允许的,所以相关操作被浏览器拒绝了.
核心技术卷II中的相关章节,有详述
URL u = new URL(/tech-qa-java/urlName/index.html);
getAppletContext().showDocument(u);
你在访问applet所在主机以外的地址,这是applet权限所不允许的,所以相关操作被浏览器拒绝了.
核心技术卷II中的相关章节,有详述
|
http://java.sun.com/products/plugin/index.html