2个回答
展开全部
全实现,程序太长,发不上去,先实现基本的 图形用户界面
import java.awt.*;
import java.awt.event.*;
public class TestMenu {
public static void main (String[] args) {
new MenuFrame("新建"+" "+"文本文档"+".txt"+" "+"-"+" "+"记事本").launchFrame();
}
}
class MenuFrame extends Frame {
MenuBar mb = null;
MenuFrame (String s) {
super (s);
}
public void launchFrame() {
Menu file = new Menu ("文件");
Menu edit = new Menu ("编辑");
Menu format = new Menu ("格式");
Menu help = new Menu ("帮助");
MenuItem newItem = new MenuItem ("新建");
newItem.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
final Frame ff = new Frame ("记事本");
ff.setMenuBar(mb);
ff.setBounds (300,300,400,200);
ff.setVisible (true);
ff. addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e) {
ff.setVisible (false);
}
} );
}
});
MenuItem saveItem = new MenuItem ("保存");
MenuItem exitItem = new MenuItem ("退出");
MenuItem helpTitle = new MenuItem ("帮助主题");
MenuItem line = new MenuItem ("-");
MenuItem about = new MenuItem ("关于记事本");
MenuItem copy = new MenuItem ("粘贴");
MenuItem serach = new MenuItem ("查找");
edit.add (copy);
edit.add (serach);
help.add (helpTitle);
help.add (line);
help.add (about);
exitItem.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
System.exit (0);
}
} );
file.add (newItem);
file.add (saveItem);
file.add (exitItem);
mb = new MenuBar();
mb.add (file);
mb.add (edit);
mb.add (format);
mb.add (help);
addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e) {
System.exit (0);
}
} );
setLayout (new FlowLayout());
setMenuBar (mb);
setBounds (300,300,400,200);
setVisible (true);
}
}
import java.awt.*;
import java.awt.event.*;
public class TestMenu {
public static void main (String[] args) {
new MenuFrame("新建"+" "+"文本文档"+".txt"+" "+"-"+" "+"记事本").launchFrame();
}
}
class MenuFrame extends Frame {
MenuBar mb = null;
MenuFrame (String s) {
super (s);
}
public void launchFrame() {
Menu file = new Menu ("文件");
Menu edit = new Menu ("编辑");
Menu format = new Menu ("格式");
Menu help = new Menu ("帮助");
MenuItem newItem = new MenuItem ("新建");
newItem.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
final Frame ff = new Frame ("记事本");
ff.setMenuBar(mb);
ff.setBounds (300,300,400,200);
ff.setVisible (true);
ff. addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e) {
ff.setVisible (false);
}
} );
}
});
MenuItem saveItem = new MenuItem ("保存");
MenuItem exitItem = new MenuItem ("退出");
MenuItem helpTitle = new MenuItem ("帮助主题");
MenuItem line = new MenuItem ("-");
MenuItem about = new MenuItem ("关于记事本");
MenuItem copy = new MenuItem ("粘贴");
MenuItem serach = new MenuItem ("查找");
edit.add (copy);
edit.add (serach);
help.add (helpTitle);
help.add (line);
help.add (about);
exitItem.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
System.exit (0);
}
} );
file.add (newItem);
file.add (saveItem);
file.add (exitItem);
mb = new MenuBar();
mb.add (file);
mb.add (edit);
mb.add (format);
mb.add (help);
addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e) {
System.exit (0);
}
} );
setLayout (new FlowLayout());
setMenuBar (mb);
setBounds (300,300,400,200);
setVisible (true);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
晕死,你去Jdk 目录里 的 Demo 找, 忘了哪个文件夹 里 有记事本,人家sun公司编好的,源代码也开放的 自己找找吧,我就一直用那个记事本
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询