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

📄 generaltext.html

📁 jsf、swing的官方指南
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html>    <head>        <title>Text Component Features (The Java&trade; Tutorials &gt;             Creating a GUI with JFC/Swing &gt; Using Swing Components)</title><style type="text/css">    .FigureCaption   {         margin-left: 1in;         margin-right: 1in;         font-family: sans-serif;         font-size: smaller;         text-align: justify;    }    #TopBar_bl {        background: url(../../images/java_bar_bl.gif) 0 100% no-repeat;        width: 100%;        height: 60px;    }    #TopBar_br {        background: url(../../images/java_bar_br.gif) 100% 100% no-repeat;        width: 100%;        height: 60px;    }    #TopBar_tl {        background: url(../../images/java_bar_tl.gif) 0 0 no-repeat;        width: 100%;        height: 60px;    }    #TopBar_tr {        background: url(../../images/java_bar_tr.gif) 100% 0 no-repeat;        width: 100%;        height: 60px;    }    #TopBar {        background: #35556B url(../../images/java_bar.gif);        margin: 10px 10px 0 10px;        height:60px;        min-width:700px;        color: white;        font-family: sans-serif;         font-weight: bold;    }    @media print {        #BreadCrumbs, #Download {            display: none;        }    }    #TopBar_right {        line-height: 14px;        float: right;        padding-top: 2px;        padding-right: 30px;        text-align: center;    }    @media print {        #TopBar_right {            display: none;        }    }    #TopBar_right a {        font-size: 12px;        margin: 3px;        padding: 0;    }    #TopBar a:visited, #TopBar a:link {        color: white;        text-decoration: none;    }    #TopBar a:hover, #TopBar a:active  {        background-color: white;        color: #35556B;    }    #BreadCrumbs {        padding: 4px 5px 0.5em 0;        font-family: sans-serif;         float: right;    }    #BreadCrumbs a {        color: blue;    }    #BreadCrumbs a:visited, #BreadCrumbs a:link {        text-decoration: none;    }    #BreadCrumbs a:hover, #BreadCrumbs a:active {        text-decoration: underline;    }    #PageTitle {        margin: 0 5px 0.5em 0;        color: #E76F00;        font-family: sans-serif;         font-weight: bold;        font-size: 20px;    }    .LeftBar_shown {        width: 13em;        float: left;        margin-left: 10px;        margin-top: 4px;        margin-bottom: 2em;    }    @media print {        .LeftBar_shown {            display: none;        }    }    .LeftBar_hidden {        display: none;    }    #Footer {        padding-top: 10px;        padding-left: 10px;        margin-right: 10px;    }    .NavBit  {        padding: 4px 5px 0.5em 0;        font-family: sans-serif;     }    @media print {        .NavBit {            display: none;        }    }    #TagNotes {        text-align: right;        font-size: smaller;        font-family: sans-serif;     }    @media print {        #TagNotes a:visited, #TagNotes a:link {            color: #35556B;            text-decoration: none;        }    }    #Contents a, .NavBit a, #TagNotes a {        color: blue    }    #TagNotes a:visited, #TagNotes a:link,    #Contents a:visited, #Contents a:link,    .NavBit a:visited, .NavBit a:link {        text-decoration: none;    }    #TagNotes a:hover, #TagNotes a:active,       #Contents a:hover, #Contents a:active,       .NavBit a:hover, .NavBit a:active {          text-decoration: underline;    }    #Contents {        float: left;        font-family: sans-serif;     }    @media print {        #Contents {            display: none;        }    }    @media screen {        div.PrintHeaders {            display: none;        }    }    .linkLESSON, .nolinkLESSON {        margin-left: 0.5em;        text-indent: -0.5em    }    .linkAHEAD, .nolinkAHEAD, .linkQUESTIONS, .nolinkQUESTIONS   {        margin-left: 1.5em;         text-indent: -0.5em    }    .linkBHEAD, .nolinkBHEAD   {        margin-left: 2.5em;        text-indent: -0.5em    }    .linkCHEAD, .nolinkCHEAD   {        margin-left: 3.5em;        text-indent: -0.5em    }    .nolinkLESSON, .nolinkAHEAD, .nolinkBHEAD, .nolinkCHEAD,    .nolinkQUESTIONS {        font-weight: bold;        color: #E76F00;    }    .MainFlow_indented {        margin-right: 10px;        margin-left: 15em;        margin-bottom: 2em;    }    .MainFlow_wide {        margin-right: 10px;        margin-left: 10px;        margin-bottom: 2em;    }    @media print {        .MainFlow_indented, .MainFlow_wide {            padding-top: 0;            margin-top: 10px;            margin-right: 10px;            margin-left: 0;        }    }    h3, h4, h5 {        color: #E76F00;        font-family: sans-serif;    }    #ToggleLeft {        display: none;    }    /t</style><script type="text/javascript">    function leftBar() {        var nameq = 'tutorial_showLeftBar='        var cookies = document.cookie.split(';');        for (var i = 0; i < cookies.length; i++) {            var cookieString = cookies[i];            while (cookieString.charAt(0) == ' ') {                cookieString = cookieString.substring(1, cookieString.length);            }            if (cookieString.indexOf(nameq) == 0) {                cookieValue =  cookieString.substring(nameq.length,                        cookieString.length);                return cookieValue == 'yes';            }        }        return true;    }    function showLeft(b) {        var contents = document.getElementById("LeftBar");        var main = document.getElementById("MainFlow");        var toggle = document.getElementById("ToggleLeft");        if (b) {            contents.className = "LeftBar_shown";            main.className = "MainFlow_indented";            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> Using Swing Components        <br><b>Section:</b> Using Text Components    </div>    <div id=LeftBar class=LeftBar_shown>        <div id=Contents>            <div class="linkLESSON"><a href="index.html">Using Swing Components</a></div><div class="linkAHEAD"><a href="components.html">A Visual Index to the Swing Components</a></div><div class="linkAHEAD"><a href="html.html">Using HTML in Swing Components</a></div><div class="linkAHEAD"><a href="toplevel.html">Using Top-Level Containers</a></div><div class="linkAHEAD"><a href="model.html">Using Models</a></div><div class="linkAHEAD"><a href="jcomponent.html">The JComponent Class</a></div><div class="linkAHEAD"><a href="text.html">Using Text Components</a></div><div class="nolinkBHEAD">Text Component Features</div><div class="linkBHEAD"><a href="textapi.html">The Text Component API</a></div><div class="linkAHEAD"><a href="componentlist.html">How to Use Various Components</a></div><div class="linkBHEAD"><a href="applet.html">How to Make Applets</a></div><div class="linkBHEAD"><a href="button.html">How to Use Buttons, Check Boxes, and Radio Buttons</a></div><div class="linkBHEAD"><a href="colorchooser.html">How to Use Color Choosers</a></div><div class="linkBHEAD"><a href="combobox.html">How to Use Combo Boxes</a></div><div class="linkBHEAD"><a href="dialog.html">How to Make Dialogs</a></div><div class="linkBHEAD"><a href="editorpane.html">How to Use Editor Panes and Text Panes</a></div><div class="linkBHEAD"><a href="filechooser.html">How to Use File Choosers</a></div><div class="linkBHEAD"><a href="formattedtextfield.html">How to Use Formatted Text Fields</a></div><div class="linkBHEAD"><a href="frame.html">How to Make Frames (Main Windows)</a></div><div class="linkBHEAD"><a href="internalframe.html">How to Use Internal Frames</a></div><div class="linkBHEAD"><a href="label.html">How to Use Labels</a></div><div class="linkBHEAD"><a href="layeredpane.html">How to Use Layered Panes</a></div><div class="linkBHEAD"><a href="list.html">How to Use Lists</a></div><div class="linkBHEAD"><a href="menu.html">How to Use Menus</a></div><div class="linkBHEAD"><a href="panel.html">How to Use Panels</a></div><div class="linkBHEAD"><a href="passwordfield.html">How to Use Password Fields</a></div><div class="linkBHEAD"><a href="progress.html">How to Use Progress Bars</a></div><div class="linkBHEAD"><a href="rootpane.html">How to Use Root Panes</a></div><div class="linkBHEAD"><a href="scrollpane.html">How to Use Scroll Panes</a></div><div class="linkBHEAD"><a href="separator.html">How to Use Separators</a></div><div class="linkBHEAD"><a href="slider.html">How to Use Sliders</a></div><div class="linkBHEAD"><a href="spinner.html">How to Use Spinners</a></div><div class="linkBHEAD"><a href="splitpane.html">How to Use Split Panes</a></div><div class="linkBHEAD"><a href="tabbedpane.html">How to Use Tabbed Panes</a></div><div class="linkBHEAD"><a href="table.html">How to Use Tables</a></div><div class="linkBHEAD"><a href="textarea.html">How to Use Text Areas</a></div><div class="linkBHEAD"><a href="textfield.html">How to Use Text Fields</a></div><div class="linkBHEAD"><a href="toolbar.html">How to Use Tool Bars</a></div><div class="linkBHEAD"><a href="tooltip.html">How to Use Tool Tips</a></div><div class="linkBHEAD"><a href="tree.html">How to Use Trees</a></div><div class="linkAHEAD"><a href="icon.html">How to Use Icons</a></div><div class="linkAHEAD"><a href="border.html">How to Use Borders</a></div><div class="linkAHEAD"><a href="problems.html">Solving Common Component 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>Using Swing Components</a>            </span>            <div class=NavBit>                <a target=_top href=text.html>&laquo;&nbsp;Previous</a>&nbsp;&bull;&nbsp;<a target=_top href=../TOC.html>Trail</a>&nbsp;&bull;&nbsp;<a target=_top href=textapi.html>Next&nbsp;&raquo;</a>            </div>            <div id=PageTitle>Text Component Features</div>            <blockquote><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html"><code>JTextComponent</code></a> is the foundation for Swing's text components,and provides these customizablefeatures for all of its descendants:<ul><li> A model, known as a <em>document</em>,     to manage the component's content.<li> A view, which is in charge of displaying the     component on screen. <li> A controller, known as an <em>editor kit</em>,     that can read and write text     and that implements editing capabilities with<a class="TutorialLink" target="_top" href="../misc/action.html">actions</a>.<li> Support for infinite undo and redo.<li> Pluggable caret and support for caret change listeners     and navigation filters.</ul>This section uses the application shown belowto explore these capabilities.Although the demo applicationcontains a customized instance of <code>JTextPane</code>,the capabilities discussed in this sectionare inherited by all of <code>JTextComponent</code>'s subclasses.<p><center><IMG SRC="../../figures/uiswing/components/TextComponentDemoMetal.png" WIDTH="343" HEIGHT="368" ALIGN="BOTTOM" ALT="A snapshot of TextComponentDemo, which contains a customized text pane and a standard text area"></center></p>The upper text component is the customized text pane.The lower text component is an instance of <code>JTextArea</code>,which serves as a log that reports all changesmade to the contents of the text pane.The status line at the bottom of the window reports eitherthe location of the selection or the position of the caret,depending on whether text is selected.<blockquote><hr><strong>Try this:</strong>&nbsp;<ol><li> <a href="http://java.sun.com/docs/books/tutorialJWS/uiswing/components/examples/TextComponentDemo.jnlp">Run TextComponentDemo</a> (it requires release 6) using<a class="TutorialLink" target="_top" href="../../information/javawebstart.html">Java<sup><font size=-2>TM</font></sup> Web Start</a>.    Or, to compile and run the example yourself,     consult the     <a href="examples/index.html#TextComponentDemo">example index</a>.<li> Use the mouse to select text and place the cursor     in the text pane.     Information about the selection and cursor     is displayed at the bottom of the window.<li> Enter text by typing at the keyboard.     You can move the caret around using four emacs key bindings:     <code>CTRL-B</code> (backward one character),     <code>CTRL-F</code> (forward one character),     <code>CTRL-N</code> (down one line), and     <code>CTRL-P</code> (up one line).<li> Bring up the <strong>Edit</strong> menu,     and use its various menu items to perform editing     on the text in the text pane.     Make a selection in the text area     at the bottom of the window.     Because the text area is uneditable,     only some of the <strong>Edit</strong> menu's commands,     like <strong>copy-to-clipboard</strong>, work.

⌨️ 快捷键说明

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