该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
@SuppressWarnings("serial")
public class Note extends JFrame implements ActionListener{
JMenuBar menu;//菜单
JMenu menu1,menu2,menu3,menu4,menu5;
JMenuItem menus2,menus3,menus4,menus5,menus6,menus7;//菜单里除新建的其它选项
JMenu newFile;//新建
JMenuItem newFile1,newFile2;//新建菜单下的两个选项
JToolBar jToolBar;//工具条
JButton button1,button2,button3,button4,button5,button6;
JTextArea textAreaOutput;//文本显示区
JScrollPane scroll;//滚动条
public static void main(String[] args){
Note W=new Note();
}
Note()//构造函数
{
jToolBar=new JToolBar();
button1=new JButton(new ImageIcon("image/newFile.jpg"));
button1.setToolTipText("新建");
button2=new JButton(new ImageIcon("image/open.jpg"));
button2.setToolTipText("打开");
button3=new JButton(new ImageIcon("image/save.jpg"));
button3.setToolTipText("保存");
button4=new JButton(new ImageIcon("image/cut.jpg"));
button4.setToolTipText("剪切");
button5=new JButton(new ImageIcon("image/copy.jpg"));
button5.setToolTipText("复制");
button6=new JButton(new ImageIcon("image/paste.jpg"));
button6.setToolTipText("粘贴");
menu=new JMenuBar();
menu1=new JMenu("文件(F)");
menu1.setMnemonic('F');
menu2=new JMenu("编辑(E)");
menu2.setMnemonic('E');
menu3=new JMenu("格式(O)");
menu3.setMnemonic('O');
menu4=new JMenu("查看(V)");
menu4.setMnemonic('V');
menu5=new JMenu("帮助(H)");
menu5.setMnemonic('H');
newFile=new JMenu("新建");
newFile1=new JMenuItem("文件",new ImageIcon("image/newFile.jpg"));
newFile2=new JMenuItem("模板");
menus2=new JMenuItem("打开",new ImageIcon("image/open.jpg") );
menus2.addActionListener((ActionListener) this);
menus2.setActionCommand("open");
menus3=new JMenuItem("保存(s)",new ImageIcon("image/save.jpg") );
menus3.setMnemonic('S');
menus3.addActionListener(this);
menus3.setActionCommand("save");