⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ekit.java

📁 JTREE的例子
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            super(insertContentAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if ((target != null) && (e != null)) {		if ((! target.isEditable()) || (! target.isEnabled())) {		    target.getToolkit().beep();		    return;		}                String content = e.getActionCommand();                if (content != null) {                    target.replaceSelection(content);                } else {                    target.getToolkit().beep();                }            }        }    }    /**     * Places a line/paragraph break into the document.     * If there is a selection, it is removed before     * the break is added.     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases.  The current serialization support is appropriate     * for short term storage or RMI between applications running the same     * version of Swing.  A future release of Swing will provide support for     * long term persistence.     *     * @see DefaultEditorKit#insertBreakAction     * @see DefaultEditorKit#getActions     */    public static class InsertBreakAction extends TextAction {        /**         * Creates this object with the appropriate identifier.         */        public InsertBreakAction() {            super(insertBreakAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {//System.out.println("break");            Xeditor edit = (Xeditor)getTextComponent(e);            if (edit != null) {		if ((! edit.isEditable()) || (! edit.isEnabled())) {		    edit.getToolkit().beep();		    return;		}                try{                  int line=edit.getLineOfOffset(edit.getCaret().getDot());                  int offset=edit.getLineStartOffset(line);                  String s="";                  while(true){                    char ch=(edit.getText(offset,1)).charAt(0);                    if(ch==' '){                      s+=" ";    offset++;                    }else if(ch=='\r') {                      offset++; continue;                    }else break;                  }                  edit.replaceSelection("\n"+s);                }catch(Exception xe){                  xe.printStackTrace();                  Toolkit.getDefaultToolkit().beep();                }            }        }    }    /**     * Places a tab character into the document. If there     * is a selection, it is removed before the tab is added.     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases.  The current serialization support is appropriate     * for short term storage or RMI between applications running the same     * version of Swing.  A future release of Swing will provide support for     * long term persistence.     *     * @see DefaultEditorKit#insertTabAction     * @see DefaultEditorKit#getActions     */    public static class InsertTabAction extends TextAction {        /**         * Creates this object with the appropriate identifier.         */        public InsertTabAction() {            super(insertTabAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if (target != null) {		if ((! target.isEditable()) || (! target.isEnabled())) {		    target.getToolkit().beep();		    return;		}                target.replaceSelection("  ");            }        }    }    /*     * Deletes the character of content that precedes the     * current caret position.     * @see DefaultEditorKit#deletePrevCharAction     * @see DefaultEditorKit#getActions     */    static class DeletePrevCharAction extends TextAction {        /**         * Creates this object with the appropriate identifier.         */        DeletePrevCharAction() {            super(deletePrevCharAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            boolean beep = true;            if ((target != null) && (target.isEditable())) {                try {                    Document doc = target.getDocument();                    Caret caret = target.getCaret();                    int dot = caret.getDot();                    int mark = caret.getMark();                    if (dot != mark) {                        doc.remove(Math.min(dot, mark), Math.abs(dot - mark));                        beep = false;                    } else if (dot > 0) {                        doc.remove(dot - 1, 1);                        beep = false;                    }                } catch (BadLocationException bl) {                }            }            if (beep) {                Toolkit.getDefaultToolkit().beep();            }        }    }    /*     * Deletes the character of content that follows the     * current caret position.     * @see DefaultEditorKit#deleteNextCharAction     * @see DefaultEditorKit#getActions     */    static class DeleteNextCharAction extends TextAction {        /* Create this object with the appropriate identifier. */        DeleteNextCharAction() {            super(deleteNextCharAction);        }        /** The operation to perform when this action is triggered. */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            boolean beep = true;            if ((target != null) && (target.isEditable())) {                try {                    Document doc = target.getDocument();                    Caret caret = target.getCaret();                    int dot = caret.getDot();                    int mark = caret.getMark();                    if (dot != mark) {                        doc.remove(Math.min(dot, mark), Math.abs(dot - mark));                        beep = false;                    } else if (dot < doc.getLength()) {                        doc.remove(dot, 1);                        beep = false;                    }                } catch (BadLocationException bl) {                }            }            if (beep) {                Toolkit.getDefaultToolkit().beep();            }        }    }    /*     * Sets the editor into read-only mode.     * @see DefaultEditorKit#readOnlyAction     * @see DefaultEditorKit#getActions     */    static class ReadOnlyAction extends TextAction {        /* Create this object with the appropriate identifier. */        ReadOnlyAction() {            super(readOnlyAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if (target != null) {                target.setEditable(false);            }        }    }    /*     * Sets the editor into writeable mode.     * @see DefaultEditorKit#writableAction     * @see DefaultEditorKit#getActions     */    static class WritableAction extends TextAction {        /* Create this object with the appropriate identifier. */        WritableAction() {            super(writableAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if (target != null) {                target.setEditable(true);            }        }    }    /**     * Cuts the selected region and place its contents     * into the system clipboard.     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases.  The current serialization support is appropriate     * for short term storage or RMI between applications running the same     * version of Swing.  A future release of Swing will provide support for     * long term persistence.     *     * @see DefaultEditorKit#cutAction     * @see DefaultEditorKit#getActions     */    public static class CutAction extends TextAction {        /** Create this object with the appropriate identifier. */        public CutAction() {            super(cutAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if (target != null) {                target.cut();            }        }    }    /**     * Coies the selected region and place its contents     * into the system clipboard.     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases.  The current serialization support is appropriate     * for short term storage or RMI between applications running the same     * version of Swing.  A future release of Swing will provide support for     * long term persistence.     *     * @see DefaultEditorKit#copyAction     * @see DefaultEditorKit#getActions     */    public static class CopyAction extends TextAction {        /** Create this object with the appropriate identifier. */        public CopyAction() {            super(copyAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if (target != null) {                target.copy();            }        }    }    /**     * Pastes the contents of the system clipboard into the     * selected region, or before the caret if nothing is     * selected.     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases.  The current serialization support is appropriate     * for short term storage or RMI between applications running the same     * version of Swing.  A future release of Swing will provide support for     * long term persistence.     *     * @see DefaultEditorKit#pasteAction     * @see DefaultEditorKit#getActions     */    public static class PasteAction extends TextAction {        /** Create this object with the appropriate identifier. */        public PasteAction() {            super(pasteAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            JTextComponent target = getTextComponent(e);            if (target != null) {                target.paste();            }        }    }    /**     * Creates a beep.     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases.  The current serialization support is appropriate     * for short term storage or RMI between applications running the same     * version of Swing.  A future release of Swing will provide support for     * long term persistence.     *     * @see DefaultEditorKit#beepAction     * @see DefaultEditorKit#getActions     */    public static class BeepAction extends TextAction {        /** Create this object with the appropriate identifier. */        public BeepAction() {            super(beepAction);        }        /**         * The operation to perform when this action is triggered.         *         * @param e the action event         */        public void actionPerformed(ActionEvent e) {            Toolkit.getDefaultToolkit().beep();        }    }    /**     * Pages up vertically.  The select version of this action extends     * the selection, instead of simply moving the caret.     *     * @see DefaultEditorKit#pageUpAction     * @see DefaultEditorKit#selectPageUpAction     * @see DefaultEditorKit#getActions     */    static class PageUpAction extends TextAction {	/** Create this object with the appropriate identifier. */	public PageUpAction(String nm, boolean select) {	    super(nm);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -