| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 856 人关注过本帖
标题:为什么程序出现没有初始化小程序??
只看楼主 加入收藏
李贤昌
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-12-15
收藏
 问题点数:0 回复次数:3 
为什么程序出现没有初始化小程序??
代码:
import java.awt.*;
import java.awt.event.*;
public class E20
{
    public static void main(String args[])
    {
        myMenuFrame myMenu=new myMenuFrame();
        myMenu.setVisible(true);
    }
}
class myMenuFrame extends Frame implements ActionListener,ItemListener
{
    TextField text;
    PopupMenu popM;
    Button but;
    public myMenuFrame()
    {
        super("我的菜单窗口");
        setLayout(new BorderLayout());
        setSize(300,200);
        but=new Button("弹出菜单按键");
        add("North",but);
        this.add(but);
        but.addActionListener(this);
        MenuBar myB=new MenuBar();
        setMenuBar(myB);
        Menu m1=new Menu("文件");
        MenuItem m11=new MenuItem("打开");
        MenuItem m12=new MenuItem("保存");
        MenuShortcut sc1=new MenuShortcut(KeyEvent.VK_O);
        MenuShortcut sc2=new MenuShortcut(KeyEvent.VK_E);
        m11.setShortcut(sc1);
        m12.setShortcut(sc2);
        m1.add(m11);  m1.add(m12);
        m1.addSeparator();
        MenuItem m13=new MenuItem("退出",new MenuShortcut(KeyEvent.VK_X));
        m1.add(m13);
        m1.addActionListener(this);
        myB.add(m1);
        popM=new PopupMenu();
        MenuItem p1=new MenuItem("复制");
        p1.addActionListener(this);
        popM.add(p1);
        MenuItem p2=new MenuItem("剪切");
        p2.addActionListener(this);
        popM.add(p2);
        MenuItem p3=new MenuItem("粘贴");
        p3.addActionListener(this);
        popM.add(p3);
        but.add(popM);
        text=new TextField();
        add("South",text);
    }
    
    public void itemStateChanged(ItemEvent e)
    {
        text.setText("状态改变");
    }
    
    public void actionPerformed(ActionEvent e)
    {
        text.setText(e.getActionCommand());
        if(e.getActionCommand()=="弹出菜单按键")
           popM.show(but,50,70);
           if(e.getActionCommand()=="退出")
             System.exit(0);
    }
}
可以编绎通过!
HTML文件为:
<html>
<body>
<applet code="E20.class" height="300" width="500"></applet>
</body>
</html>
但运行是出现:没有初始化小程序!
2008-02-26 00:13
xiaozhefei
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2007-9-26
收藏
得分:0 
你继承的不是applet类把class myMenuFrame extends Frame implements ActionListener,ItemListener 改为class myMenuFrame extends applet implements ActionListener,ItemListener
试下
2008-02-26 08:52
jgio
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2008-2-18
收藏
得分:0 
www.  慧都控件网,国内最大的专业控件代理商与技术支持商
tel:023-66090381   QQ:903506412
2008-02-26 09:45
论坛元老
Rank: 1
等 级:新手上路
帖 子:812
专家分:0
注 册:2008-3-31
收藏
得分:0 
你继承的不是applet类把class myMenuFrame extends Frame implements ActionListener,ItemListener 改为class myMenuFrame extends applet implements ActionLis ...
2008-04-02 18:41
快速回复:为什么程序出现没有初始化小程序??
数据加载中...
 
   



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

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