文件名称:java编写的类似文本编辑器的代码
文件大小:30KB
文件格式:JAVA
更新时间:2011-12-19 05:20:00
编辑器
java编写的类似文本编辑器的代码 import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.event.*; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.BufferedReader; import java.io.IOException; import java.io.BufferedInputStream; import javax.swing.*; import javax.swing.border.BevelBorder; import javax.swing.event.*; import javax.swing.filechooser.FileFilter; import javax.swing.text.BadLocationException; import javax.swing.tree.DefaultMutableTreeNode; public class SimpleEditor extends JFrame //继承窗体类 { /*定义菜单栏,菜单和菜单选项*/ JMenuBar menuBar1=new JMenuBar(); JMenu fileMenu=new JMenu("File"); JMenu editMenu=new JMenu("Edit"); JMenu optionMenu=new JMenu("Option"); JMenu advanceMenu=new JMenu("Advance"); JMenu helpMenu=new JMenu("Help"); JMenuItem newMenuItem=new JMenuItem("new"); JMenuItem openMenuItem=new JMenuItem("Open"); JMenuItem saveMenuItem=new JMenuItem("Save"); JMenuItem exitMenuItem=new JMenuItem("exit"); JMenuItem findMenuItem=new JMenuItem("Find"); JMenuItem findNextMenuItem=new JMenuItem("Find Next"); JMenuItem replaceMenuItem=new JMenuItem("Replace"); JMenuItem compileMenuItem=new JMenuItem("Compile"); JMenuItem buildMenuItem=new JMenuItem("Build"); JMenuItem stopFlashMenuItem=new JMenuItem("Stop Flash"); JMenuItem startFlashMenuItem=new JMenuItem("Start Flash"); JMenuItem helpMenuItem=new JMenuItem("Help"); JMenuItem copyMenuItem=new JMenuItem("Copy"); JMenuItem cutMenuItem=new JMenuItem("Cut"); JMenuItem pasteMenuItem=new JMenuItem("Paste"); /*文件内容显示区*/ JTextArea[] fileTextAreas=new JTextArea[10];//文件区 JTextArea concloseTextArea=new JTextArea(); //控制台信息 JScrollPane [] fileScrollPanes=new JScrollPane[10];//文件视图 JScrollPane concloseScrollPane;//控制台的视图 JTabbedPane fileTabbedPane=new JTabbedPane();//视图的切换用 /*工具栏及工具栏上的按钮*/ JToolBar toolBar=new JToolBar(); JButton openButton=new JButton(new ImageIcon(loadImage("image/open.GIF"))); JButton newButton=new JButton(new ImageIcon(loadImage("image/new.GIF"))); JButton saveButton=new JButton(new ImageIcon(loadImage("image/save.GIF"))); JButton helpButton=new JButton(new ImageIcon(loadImage("image/help.GIF"))); JButton exitButton=new JButton(new ImageIcon(loadImage("image/close.GIF"))); JButton compileButton=new JButton(new ImageIcon(loadImage("image/compile.GIF"))); JButton buildButton=new JButton(new ImageIcon(loadImage("image/build.GIF"))); JButton copyButton=new JButton(new ImageIcon(loadImage("image/copy.GIF"))); JButton cutButton=new JButton(new ImageIcon(loadImage("image/cut.GIF"))); JButton pasteButton=new JButton(new ImageIcon(loadImage("image/paste.GIF")));