一个小的文本编辑器:import ActionListener;import EventListener;import *;import *;import *;import *;import *;import *;public class MiniEdit extends JFrame implements ActionListener { /** * Method main * * * @param args * */ MenuBar menuBar = new MenuBar(); Menu file = new Menu("File"), edit = new Menu("Edit"), help = new Menu("Help"); MenuItem[] menuItem ={ new MenuItem("New"), new MenuItem("Open"), new MenuItem("Save"), new MenuItem("Exit"), new MenuItem("Select All"), new MenuItem("Copy"), new MenuItem("Cut"), new MenuItem("Paste"), new MenuItem("Help") }; TextArea textArea = new TextArea(); String fileName = "NoName"; Toolkit toolKit = TDefaultToolkit(); Clipboard clipboard = toolKSystemClipboard(); //opne and close message dialogs private FileDialog openFileDialog = new FileDialog(this,"Open File",FileDLOAD); private FileDialog saveFileDialog = new FileDialog(this,"Save File",FileDSAVE); public static void main(String[] args) { // TODO: Add your code here MiniEdit MyEdit = new MiniEdit(); MyEshow(); } /** * Method MiniEdit * * */ public MiniEdit() { // TODO: Add your code here setTitle("MiniEdit"); setFont(new Font("Times New Roman",FPLAIN,15)); setBackground(Cblue); setSize(500,500); setMenuBar(menuBar); menuBadd(file); menuBadd(edit); menuBadd(help); for(int i=0;i<4;i++) { add(menuItem[i]); add(menuItem[i+4]); } add(menuItem[8]); add(textArea); addWindowListener(new WindowAdapter(){//关闭窗口的事件监听 public void windowClosing(WindowEvent e){ Window()dispose(); Sxit(0); } }); //add actionListener for(int i=0;i