import java.awt.*;
import javax.swing.*;
import java.awt.event.*; //菜单包
public class Jar{
public static void main(String[] args) {
Gui win = new Gui();
}
}
class Gui extends JFrame{
JMenuBar cd; //菜单条
JMenu cd1,cd2,cd3,cd4,cd5; //菜单
JMenuItem cdx2,cdx3,cdx4,cdx5,cdx6,cdx7;
JMenu ej; //二级菜单
JMenuItem ej1,ej2; //
JToolBar gjt; //工具条
JButton bt1,bt2,bt3,bt4,bt5,bt6;
JTextArea wby;//文本域
JScrollPane gdt; //滚动条
Gui(){
gjt = new JToolBar();
bt1 = new JButton(new ImageIcon("1.png"));
bt1.setToolTipText("新建");
bt2 = new JButton(new ImageIcon("1.png"));
bt2.setToolTipText("打开");
bt3 = new JButton(new ImageIcon("1.png"));
bt3.setToolTipText("保存");
bt4 = new JButton(new ImageIcon("1.png"));
bt4.setToolTipText("剪切");
bt5 = new JButton(new ImageIcon("1.png"));
bt5.setToolTipText("复制");
bt6 = new JButton(new ImageIcon("1.png"));
bt6.setToolTipText("粘贴");
cd = new JMenuBar();
cd1 = new JMenu("文件(F)");
cd1.setMnemonic('F'); //
cd2 = new JMenu("文件(F)");
cd2.setMnemonic('F');
cd3 = new JMenu("文件(F)");
cd3.setMnemonic('F');
cd4 = new JMenu("文件(F)");
cd4.setMnemonic('F');
cd5 = new JMenu("文件(F)");
cd5.setMnemonic('F');
ej = new JMenu("新建");
ej1 = new JMenuItem("文件");//可以添加图
ej2 = new JMenuItem("模板");
cdx2 = new JMenuItem("打开");
cdx3 = new JMenuItem("保存(s)");
cdx3.setMnemonic('S');
cdx4 = new JMenuItem("另存为");
cdx5 = new JMenuItem("页面设置");
cdx6 = new JMenuItem("打印");
cdx7 = new JMenuItem("退出");
wby = new JTextArea();
gdt = new JScrollPane(wby);
gjt.add(bt1); gjt.add(bt2); gjt.add(bt3);
gjt.add(bt4); gjt.add(bt5); gjt.add(bt6);
ej.add(ej1); ej.add(ej2);
cd1.add(ej); cd1.add(cdx2); cd1.add(cdx3); cd1.add(cdx4);
cd1.addSeparator();
cd1.add(cdx5); cd1.add(cdx6);
cd1.addSeparator();
cd1.add(cdx7);
cd.add(cd1); cd.add(cd2); cd.add(cd3);
cd.add(cd4); cd.add(cd5);
this.setJMenuBar(cd);
this.add(gjt,BorderLayout.NORTH);
this.add(gdt);
//窗口设置
this.setTitle("记事本");
this.setSize(400,400);
this.setLocation(100,100);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}