java HTML文件文档编辑器 使用 JTextPane
java HTML文件文档编辑器 使用 JTextPane
/* HTMLDocumentEditor.java
* @author: Charles Bell
* @version: May 27, 2002
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.undo.*;
/**HTML文件文档编辑器*/
public class HTMLDocumentEditor extends JFrame implements ActionListener
{
/** 声明一个网页文档对象变量*/
private HTMLDocument document;
/** 创建一个文本编辑板*/
private JTextPane textPane = new JTextPane();
private boolean debug = false;
/** 声明一个文件对象变量*/
private File currentFile;
/** 侦听在当前文档上的编辑器 */
protected UndoableEditListener undoHandler = new UndoHandler();
/** 添加撤消管理器 */
protected UndoManager undo = new UndoManager();
/** 添加撤消侦听器*/
private UndoAction undoAction = new UndoAction();
/** 添加恢复侦听器*/
private RedoAction redoAction = new RedoAction();
/** 添加剪切侦听器*/
private Action cutAction = new DefaultEditorKit.CutAction();
/** 添加复制侦听器*/
private Action copyAction = new DefaultEditorKit.CopyAction();
/** 添加粘贴侦听器*/
private Action pasteAction = new DefaultEditorKit.PasteAction();
/** 添加加粗侦听器*/
private Action boldAction = new StyledEditorKit.BoldAction();
/** 添加加下划线侦听器*/
private Action underlineAction = new StyledEditorKit.UnderlineAction();
/** 添加倾斜侦听器*/
private Action italicAction = new StyledEditorKit.ItalicAction();
private Action insertBreakAction = new DefaultEditorKit.InsertBreakAction();
private HTMLEditorKit.InsertHTMLTextAction unorderedListAction = new HTMLEditorKit.InsertHTMLTextAction("Bullets", "<
相关文档:
我们来介绍一下 ==和equals()的区别,==是相等,equals()也是相等。这两个词的区别是什么呢?这是找工作时很多面试官的问题。我们来解答一下。首先我们看这么个例子。实践:
public class TestEquals {
public static void main(String[] args) {
MyDate date1 = new MyDate(14, 3, 1976);
MyDate date2 = ne ......
function createTreeMenu(){//创建一个树的面板
var treeMenu = new Ext.tree.TreePanel({
lines : true,
minSize : 150,
border : false,
root : new Ext.tree.AsyncTreeNode({text : 'root'}),
loader : new Ext.tree.TreeLoader({dataUr ......
1.File类为管理文件和目录提供了方法,其对象表示一个文件或者目录。它提供了若干方法对文件或文件夹进行操作。其中的list()方法和listFiles()方法可以起到定位特定文件的作用。
2.Object类,是所有Java类的祖先,若一个类声明时没有包含extends关键字,则其直接继承于Objetc类。其中有许多重要方法:
equals(),notify(), ......
/**
* @author he
*
*
* 把Date转换成String,以yyyy-MM-dd HH:mm:ss的形式显示
*/
public static String DateToString(Date tempDate) {
......