?? myframem3.java
字號:
import java.awt.*;
import java.awt.event.*;
class MyFramem3 extends Frame implements ActionListener
{public static void main(String args[ ])
{
MyFramem3 fr=new MyFramem3();
}
TextArea msg=new TextArea();
MenuBar mb=new MenuBar();
Menu m1=new Menu("文件");
Menu m2=new Menu("編輯");
Menu m3=new Menu("幫助");
MenuItem open=new MenuItem("打開");
MenuItem save=new MenuItem("保存");
MenuItem exit=new MenuItem("退出");
MenuItem undo=new MenuItem("撤消");
MenuItem redo=new MenuItem("重做");
MenuItem copy=new MenuItem("復制");
MenuItem cut=new MenuItem("剪切");
MenuItem paste=new MenuItem("粘貼");
FileDialog fd;
String str,filename;
MyFramem3()
{
setTitle("菜單示例");
setSize(400,300); //setBackground(Color.red);
add(msg);
mb.add(m1);
mb.add(m2);
mb.add(m3);
m1.add(open);
m1.add(save);
m1.addSeparator();
m1.add(exit);
m2.add(undo);
m2.add(redo);
m2.addSeparator();
m2.add(copy);
m2.add(cut);
m2.add(paste);
m3.add("asjkhdfjk");
m3.add("111111");
exit.addActionListener(this);
open.addActionListener(this);
save.addActionListener(this);
undo.addActionListener(this);
//xx.addActionListener(this);
setMenuBar(mb);
show();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==exit)
{
System.exit(0);
}
if(e.getSource()==open)
{
fd=new FileDialog(this,"打開文件");
fd.show();
filename=fd.getFile();
}
if(e.getSource()==save)
{
fd=new FileDialog(this,"存文件",FileDialog.SAVE);
fd.show();
filename=fd.getFile();
}
if(e.getSource()==undo)
{
msg.append("sfjkdjfk\n");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -