关闭

怎么无法运行

140人阅读 评论(0) 收藏 举报

import java.awt.event.*;
import java.awt.datatransfer.*;
class Menuss implements MouseListener{
        private TextField tf;
        private Frame fr;
        private MenuBar mb;
        private Menu m1,m2,m3;
        private MenuItem mi1,mi2,mi3;
        public void mouseDragged(MouseEvent e)
        {
                String s = "mouse dragging :X = "+e.getX()+"Y = "+e.getY();
                tf.setText(s);
        }
        public void go()
        {
                fr = new Frame("记事本");
                mb = new MenuBar();
                fr.setMenuBar(mb);
                tf = new TextField(30);
                m1 = new Menu("File");
                m2 = new Menu("Edit");
                m3 = new Menu("Help");
                mb.add(m1);
                mb.add(m2);
                mb.setHelpMenu(m3);
                mi1 = new MenuItem("save");
                mi2 = new MenuItem("Load");
                mi3 = new MenuItem("Quit");
                m1.add(mi1);
                fr.addMouseListener(this);
                m1.add(mi2);
                m1.add(mi3);
                fr.setSize(500,400);
                fr.setVisible(true);
        }
        public static void main(String args[])
        {
                Menuss k = new Menuss();
                k.go();
        }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1781次
    • 积分:63
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条