| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:在浏览器中无法显示applet运行结果的问题
只看楼主 加入收藏
yexin218
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2006-12-5
结帖率:100%
收藏
 问题点数:0 回复次数:0 
在浏览器中无法显示applet运行结果的问题
不知道为什么,我写了好多的applet程序,就是当当这个在浏览器无法正常显示---只显示一个灰色的框架。奇怪的是,其他的applet都可以,我想可能不是插件的问题了。
在命令行窗口中 appletviewer IdCardInfo.html 可以正确执行,可就是不能再浏览器打开。
<html>
<body>
<APPLET CODE="IdCardInfo.class" WIDTH="600" HEIGHT="600">

</APPLET>
</body>
</html>


applet代码如下:
import javax.swing.JApplet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventListener;

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


public class IdCardInfo extends JApplet{
private static final ChangeListener EventListener = null;
private JTabbedPane tabbedPane = null;
private JLabel photoLabel,nameLabel,pnameLabel,idNoLabel,genderLabel,birthLabel,heightLabel;
private JLabel bloodLabel;
private JLabel medicineLabel;
private JLabel equipLabel;
private JLabel historyLabel;
private JPanel infoPanel,bloodPanel,medicinePanel,equipPanel,historyPanel;
private JTextField nameField,pnameField,idNoField,genderField,birthField,heightField;
private JButton readButton,discButton,updateButton;
public IdCardInfo(){

}
public void init(){
try{
IdCardInfoInit();
}catch (Exception e){
e.printStackTrace();
}
}
private void IdCardInfoInit()throws Exception{
Container container = getContentPane();
container.setLayout(null);

nameLabel = new JLabel("Name:");
pnameLabel = new JLabel("Portuguese Name:");
idNoLabel = new JLabel("Id NO.:");
genderLabel = new JLabel("Gender:");
birthLabel = new JLabel("Day of Birth:");
heightLabel = new JLabel("Heifht:");
nameField =new JTextField(20);
pnameField = new JTextField(18);
idNoField = new JTextField(10);
genderField = new JTextField(10);
birthField = new JTextField(15);
heightField = new JTextField(20);

photoLabel = new JLabel(new ImageIcon(".\\icons\\spence.jpg"));
photoLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.red,Color.blue));
photoLabel.setBounds(15,25, 100, 150);

infoPanel = new JPanel();
infoPanel.setLayout(null);
nameLabel.setBounds(10, 30, 50, 25);
nameField.setBounds(65, 30, 380, 25);
pnameLabel.setBounds(10, 60,120, 25);
pnameField.setBounds(135, 60, 310, 25);
idNoLabel.setBounds(10, 90, 50, 25);
idNoField.setBounds(65, 90, 157, 25);
genderLabel.setBounds(226, 90, 50, 25);
genderField.setBounds(275, 90, 170, 25);
birthLabel.setBounds(10, 120, 80, 25);
birthField.setBounds(95, 120, 127, 25);
heightLabel.setBounds(226, 120, 50, 25);
heightField.setBounds(275, 120, 170, 25);

infoPanel.setBounds(120, 25, 450, 155);

infoPanel.setBorder(BorderFactory.createTitledBorder("Card Information"));

infoPanel.add(nameLabel);infoPanel.add(nameField);
infoPanel.add(pnameLabel);
//infoPanel.add(photoLabel);
infoPanel.add(pnameField);
infoPanel.add(idNoLabel);infoPanel.add(idNoField);
infoPanel.add(genderLabel);infoPanel.add(genderField);
infoPanel.add(birthLabel);infoPanel.add(birthField);
infoPanel.add(heightLabel);infoPanel.add(heightField);


bloodLabel = new JLabel("Blood Type",JLabel.CENTER);
bloodLabel.setBackground(Color.blue);
bloodPanel = new JPanel();
bloodPanel.add(bloodLabel);

medicineLabel = new JLabel("Medicine information",JLabel.CENTER);
medicinePanel = new JPanel();
medicinePanel.add(medicineLabel);

equipLabel = new JLabel("Equip information",JLabel.CENTER);
equipLabel.setBackground(Color.red);
equipLabel.setOpaque(true);
equipPanel = new JPanel();
equipPanel.add(equipLabel);

historyLabel = new JLabel("History",JLabel.CENTER);
historyPanel = new JPanel();
historyPanel.add(historyLabel);



tabbedPane = new JTabbedPane();
tabbedPane.setBorder(BorderFactory.createTitledBorder("Medicine Information"));
tabbedPane.setBounds(15, 185, 550, 300);
tabbedPane.setTabPlacement(JTabbedPane.TOP);
tabbedPane.addTab("Blood",bloodPanel);
tabbedPane.addTab("medicine",medicinePanel);
tabbedPane.addTab("equip",equipPanel);
tabbedPane.addTab("history",historyPanel);
tabbedPane.addChangeListener(new ChangeListener() {
// This method is called whenever the selected tab changes
public void stateChanged(ChangeEvent evt) {
JTabbedPane pane = (JTabbedPane)evt.getSource();

// Get current tab

}
});

//tabbedPane.addChangeListener((ChangeListener) changeListener);
readButton = new JButton("Read Info.");
discButton = new JButton("Disconnect");
updateButton = new JButton("Update");
readButton.setBounds(40, 490,100, 45);
discButton.setBounds(180, 490, 100, 45);
updateButton.setBounds(340, 490, 100, 45);
readButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
nameField.setText("Spence");
}
});
discButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
pnameField.setText("Spence");
}
});

updateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
genderField.setText("M");
}
});


container.add(infoPanel);
container.add(tabbedPane);
container.add(photoLabel);
container.add(readButton);
container.add(discButton);
container.add(updateButton);;


}
public void tabbedpaneStateChanged(ChangeEvent e){

}
public static void main(String[] args) {
IdCardInfo ici = new IdCardInfo();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(ici, BorderLayout.CENTER);
frame.setTitle("Id Card Information");
ici.init();
ici.start();
frame.setSize(600, 600);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
frame.setLocation((d.width - frameSize.width) / 2,
(d.height - frameSize.height) / 2);
frame.setVisible(true);

}
}


有兴趣的,帮忙看看,谢谢。
祝你春节快乐。
搜索更多相关主题的帖子: applet 浏览器 结果 运行 
2007-02-17 18:15
快速回复:在浏览器中无法显示applet运行结果的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015946 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved