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

📄 undoableeditlistener.html

📁 jsf、swing的官方指南
💻 HTML
📖 第 1 页 / 共 2 页
字号:
            toggle.innerHTML = "Hide the TOC";            document.cookie = 'tutorial_showLeftBar=yes; path=/';        } else {            contents.className = "LeftBar_hidden";            main.className = "MainFlow_wide";            toggle.innerHTML = "Show the TOC";            document.cookie = 'tutorial_showLeftBar=no; path=/';        }    }    function toggleLeft() {        showLeft(document.getElementById("LeftBar").className ==                "LeftBar_hidden");        document.getElementById("ToggleLeft").blur();    }    function load() {        showLeft(leftBar());        document.getElementById("ToggleLeft").style.display="inline";    }    </script>    </head><body onload="load()">    <div id=TopBar> <div id=TopBar_tr> <div id=TopBar_tl> <div id=TopBar_br> <div id=TopBar_bl>                         <div id=TopBar_right>                             <a target="_blank"                                href="http://java.sun.com/javase/6/download.jsp">Download                                the JDK</a>                            <br>                            <a href="../../search.html" target="_blank">Search the                                Tutorials</a>                            <br>                            <a href="javascript:toggleLeft()"                                id="ToggleLeft">Hide the TOC</a>                        </div>                    </div> </div> </div> </div> </div>    <div class=PrintHeaders>        <b>Trail:</b> Creating a GUI with JFC/Swing        <br><b>Lesson:</b> Writing Event Listeners        <br><b>Section:</b> Implementing Listeners for Commonly Handled Events    </div>    <div id=LeftBar class=LeftBar_shown>        <div id=Contents>            <div class="linkLESSON"><a href="index.html">Writing Event Listeners</a></div><div class="linkAHEAD"><a href="intro.html">Introduction to Event Listeners</a></div><div class="linkAHEAD"><a href="generalrules.html">General Information about Writing Event Listeners</a></div><div class="linkAHEAD"><a href="eventsandcomponents.html">Listeners Supported by Swing Components</a></div><div class="linkAHEAD"><a href="handling.html">Implementing Listeners for Commonly Handled Events</a></div><div class="linkBHEAD"><a href="actionlistener.html">How to Write an Action Listener</a></div><div class="linkBHEAD"><a href="caretlistener.html">How to Write a Caret Listener</a></div><div class="linkBHEAD"><a href="changelistener.html">How to Write a Change Listener</a></div><div class="linkBHEAD"><a href="componentlistener.html">How to Write a Component Listener</a></div><div class="linkBHEAD"><a href="containerlistener.html">How to Write a Container Listener</a></div><div class="linkBHEAD"><a href="documentlistener.html">How to Write a Document Listener</a></div><div class="linkBHEAD"><a href="focuslistener.html">How to Write a Focus Listener</a></div><div class="linkBHEAD"><a href="internalframelistener.html">How to Write an Internal Frame Listener</a></div><div class="linkBHEAD"><a href="itemlistener.html">How to Write an Item Listener</a></div><div class="linkBHEAD"><a href="keylistener.html">How to Write a Key Listener</a></div><div class="linkBHEAD"><a href="listdatalistener.html">How to Write a List Data Listener</a></div><div class="linkBHEAD"><a href="listselectionlistener.html">How to Write a List Selection Listener</a></div><div class="linkBHEAD"><a href="mouselistener.html">How to Write a Mouse Listener</a></div><div class="linkBHEAD"><a href="mousemotionlistener.html">How to Write a Mouse-Motion Listener</a></div><div class="linkBHEAD"><a href="mousewheellistener.html">How to Write a Mouse-Wheel Listener</a></div><div class="linkBHEAD"><a href="propertychangelistener.html">How to Write a Property Change Listener</a></div><div class="linkBHEAD"><a href="tablemodellistener.html">How to Write a Table Model Listener</a></div><div class="linkBHEAD"><a href="treeexpansionlistener.html">How to Write a Tree Expansion Listener</a></div><div class="linkBHEAD"><a href="treemodellistener.html">How to Write a Tree Model Listener</a></div><div class="linkBHEAD"><a href="treeselectionlistener.html">How to Write a Tree Selection Listener</a></div><div class="linkBHEAD"><a href="treewillexpandlistener.html">How to Write a Tree-Will-Expand Listener</a></div><div class="nolinkBHEAD">How to Write an Undoable Edit Listener</div><div class="linkBHEAD"><a href="windowlistener.html">How to Write Window Listeners</a></div><div class="linkAHEAD"><a href="api.html">Listener API Table</a></div><div class="linkAHEAD"><a href="problems.html">Solving Common Event-Handling Problems</a></div></div>    </div>    <div id=MainFlow class=MainFlow_indented>            <span id=BreadCrumbs>                <a href=../../index.html target=_top>Home Page</a>                &gt;                <a href=../index.html target=_top>Creating a GUI with JFC/Swing</a>                &gt;                <a href=index.html target=_top>Writing Event Listeners</a>            </span>            <div class=NavBit>                <a target=_top href=treewillexpandlistener.html>&laquo;&nbsp;Previous</a>&nbsp;&bull;&nbsp;<a target=_top href=../TOC.html>Trail</a>&nbsp;&bull;&nbsp;<a target=_top href=windowlistener.html>Next&nbsp;&raquo;</a>            </div>            <div id=PageTitle>How to Write an Undoable Edit Listener</div>            <blockquote>Undoable edit events occur when an operation that can be undoneoccurs on a component.Currently, only text components fire undoable edit events,and then only indirectly.The text component's document fires the events.For text components,undoable operations include inserting characters,deleting characters,and modifying the style of text.Programs typically listen to undoable edit events toassist in the implementation of undo and redo commands.<p>Here is the undoable edit event handling code from an applicationcalled <code>TextComponentDemo</code>.<blockquote><pre>...<em>//where initialization occurs</em><em>document</em>.addUndoableEditListener(new MyUndoableEditListener());...protected class MyUndoableEditListener implements UndoableEditListener {    public void undoableEditHappened(UndoableEditEvent e) {        //Remember the edit and update the menus        undo.addEdit(e.getEdit());        undoAction.updateUndoState();        redoAction.updateRedoState();    }}  </pre></blockquote>You can find a link to the source file for<code>TextComponentDemo</code> in the<a class="TutorialLink" target="_top" href="../components/examples/index.html#TextComponentDemo">example index for Using Swing Components</a>. For a discussion about the undoable edit listener aspectof the program see<a class="TutorialLink" target="_top" href="../components/generaltext.html#undo">Implementing Undo and Redo</a></blockquote><h3><a name="api">The Undoable Edit Listener API</a></h3><blockquote><p align=center><a name="undoableeditlistener">The UndoableEditListener   Interface</a><p><em>Because <code>UndoableEditListener</code> has only one method,   it has no corresponding adapter class.</em><table border=1><tr><th align=left>Method</th><th align=left>Purpose</th></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/event/UndoableEditListener.html#undoableEditHappened(javax.swing.event.UndoableEditEvent)">undoableEditHappened(UndoableEditEvent)</a></td><td> Called when an undoable event occurs on the listened-to component.</td></tr></table><p align=center><a name="undoableeditevent">The UndoableEditEvent Class</a><p><table border=1><tr><th align=left>Method</th><th align=left>Purpose</th></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/util/EventObject.html#getSource()">Object getSource()</a><br>(<em>in <code>java.util.EventObject</code></em>)</td><td>Return the object that fired the event.</td></tr><tr><td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/event/UndoableEditEvent.html#getEdit()">UndoableEdit getEdit()</a></td><td>Returns an<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/undo/UndoableEdit.html"><code>UndoableEdit</code></a> object that represents the editthat occurred and contains information about and commandsfor undoing or redoing the edit.</td></tr></table></blockquote><a name="eg"><h3>Examples that Use Undoable Edit Listeners</h3></a><blockquote>The following table lists theexamples that use undoable edit listeners. <p> <table><tr><th align=left> Example</th><th align=left> Where Described</th><th align=left> Notes</th></tr><tr valign=top><td> <a href="../components/examples/index.html#TextComponentDemo">     <code>TextComponentDemo</code></a></td><td><a class="TutorialLink" target="_top" href="../components/generaltext.html#undo">Implementing Undo and Redo</a></td><td> Implements undo and redo on a text pane with help from     an undoable edit listener.</td></tr></table>        </blockquote>        <div class=NavBit>            <a target=_top href=treewillexpandlistener.html>&laquo; Previous</a>            &bull;            <a target=_top href=../TOC.html>Trail</a>            &bull;            <a target=_top href=windowlistener.html>Next &raquo;</a>        </div>    </div>    <div id=Footer><div id=TagNotes>    Problems with the examples? Try <a target="_blank"        href=../../information/run-examples.html>Compiling and Running        the Examples: FAQs</a>.    <br>    Complaints? Compliments? Suggestions? <a target="_blank"        href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give    us your feedback</a>.<br><br>    <a target="_blank" href="../../information/copyright.html">Copyright</a>    1995-2006 Sun Microsystems, Inc.  All rights reserved.    <span id=Download></span></div>     </div>    <div class=PrintHeaders>        <b>Previous page:</b> How to Write a Tree-Will-Expand Listener        <br><b>Next page:</b> How to Write Window Listeners    </div>    </body></html> 

⌨️ 快捷键说明

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