eventsandcomponents.html
来自「jsf、swing的官方指南」· HTML 代码 · 共 1,178 行 · 第 1/3 页
HTML
1,178 行
<dd>Listens for mouse clicks and mouse movement into or out of the component's drawing area.<dt><strong><a href="mousemotionlistener.html">mouse-motion listener</a></strong><dd>Listens for changes in the cursor's position over the component.<dt><strong><a href="mousewheellistener.html">mouse-wheel listener</a></strong> <i>(introduced in 1.4)</i><dd>Listens for mouse wheel movement over the component.</dl><p>Two listener types introduced in release 1.3,<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/event/HierarchyListener.html"><code>HierarchyListener</code></a> and<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/awt/event/HierarchyBoundsListener.html"><code>HierarchyBoundsListener</code></a>, listen to changes to a component's containment hierarchy.These listener types aren't useful to most programs and cangenerally be ignored.<p>All Swing components descend from the AWT <code>Container</code>class, but many of them aren't used as containers. So, technically speaking, any Swing component can fire <a href="containerlistener.html">container events</a>,which notify listeners that a componenthas been added to or removed from the container.Realistically speaking, however, only containers(such as panels and frames)and compound components (such as combo boxes)typically fire container events.<p><code>JComponent</code>provides support for three more listener types.You can register an<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/event/AncestorListener.html">ancestor listener</a> to be notified when a component'scontainment ancestors are added to or removed from a container,hidden, made visible, or moved.This listener type is an implementation detail which predatedhierarchy listeners and can generally be ignored.<p>The other two listener types are part of the Swing components'conformance to theJavaBeans<sup><font size=-2>TM</font></sup> specification.Among other things, this means that Swing components supportbound and constrained propertiesand notify listeners of changes to the properties.<a href=propertychangelistener.html>Property change listeners</a>listen for changes to bound properties and are used byseveral Swing components, such as<a class="TutorialLink" target="_top" href="../components/formattedtextfield.html">formatted text fields</a>, to track changes on a component's bound properties.Also, property change listeners, as well as<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/beans/VetoableChangeListener.html">vetoable change listeners</a> are used by builder tools tolisten for changes on constrained properties.For more information refer to the<a class="TutorialLink" target="_top" href="../../javabeans/properties/index.html">Properties</a> lesson in the<a class="TutorialLink" target="_top" href="../../javabeans/">JavaBeans</a> trail.</blockquote><a name="many"><h3>Other Listeners that Swing Components Support</h3></a><blockquote>The following table lists Swing componentsand the specialized listeners they support, not includinglisteners supported by all <code>Component</code>s,<code>Container</code>s, or <code>JComponent</code>s.In many cases, the events are fireddirectly from the component.In other cases, the events are firedfrom the component's data or selection model.To find out the details for theparticular component and listener you're interested in,go first to the component how-to section,and then if necessary to the listener how-to section.<p><table border><tr><td rowspan=2 align=center><b>Component</b></td><td colspan=9 align=center><b>Listener</b></td></tr><tr><td align=center><font size=-1><a href="actionlistener.html">action</a></font></td><td align=center><font size=-1><a href="caretlistener.html">caret</a></font></td><td align=center><font size=-1><a href="changelistener.html">change</a></font></td><td align=center><font size=-1><a href="documentlistener.html">document</a>,<br> <a href="undoableeditlistener.html">undoable edit</a></font></td><td align=center><font size=-1><a href="itemlistener.html">item</a></font></td><td align=center><font size=-1> <a href="listselectionlistener.html">list<br>selection</a></font></td><td align=center><font size=-1> <a href="windowlistener.html">window</a></font></td><td align=center><font size=-1>other</font></td></tr><tr><td><a href="../components/button.html">button</a></td><td align=center><!-- action --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- caret --> </td><td align=center><!-- change --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- document --> </td><td align=center><!-- item --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> </td></tr><tr><td><a href="../components/button.html#checkbox">check box</a></td><td align=center><!-- action --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- caret --> </td><td align=center><!-- change --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- document --> </td><td align=center><!-- item --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> </td></tr><tr><td> <a href="../components/colorchooser.html">color chooser</a></td><td align=center><!-- action --> </td><td align=center><!-- caret --> </td><td align=center><!-- change --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> </td></tr><tr><td><a href="../components/combobox.html">combo box</a></td><td align=center><!-- action --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> </td></tr><tr> <td> <a href="../components/dialog.html">dialog</a> </td><td align=center><!-- action --> </td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- other --> </td></tr><tr><td><a href="../components/editorpane.html">editor pane</a></td><td align=center><!-- action --> </td><td align=center><!-- caret --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- change --> </td><td align=center><!-- document --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/event/HyperlinkListener.html"><font size=-1>hyperlink</font></a> </td></tr><tr> <td><a href="../components/filechooser.html">file chooser</a></td><td align=center><!-- action --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> </td></tr><tr><td> <a href="../components/formattedtextfield.html">formatted text field</a></td><td align=center><!-- action --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- caret --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- change --> </td><td align=center><!-- document --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> </td></tr><tr> <td> <a href="../components/frame.html">frame</a></td><td align=center><!-- action --> </td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- other --> </td></tr><tr><td><a href="../components/internalframe.html">internal frame</a></td><td align=center><!-- action --> </td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> <font size=-1><a href="internalframelistener.html">internal frame</a></font> </td></tr><tr> <td> <a href="../components/list.html">list</a> </td><td align=center><!-- action --> </td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- window --> </td><td align=center><!-- other --> <font size=-1><a href="listdatalistener.html">list data</a></font></td></tr><tr><td><a href="../components/menu.html">menu</a></td><td align=center><!-- action --> </td><td align=center><!-- caret --> </td><td align=center><!-- change --> </td><td align=center><!-- document --> </td><td align=center><!-- item --> </td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td><td align=center><!-- other --> <font size=-1><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/event/MenuListener.html">menu</a> </font></td></tr><tr><td><a href="../components/menu.html">menu item</a></td><td align=center><!-- action --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- caret --> </td><td align=center><!-- change --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- document --> </td><td align=center><!-- item --><p><center><IMG SRC="../../figures/uiswing/../../images/check.gif" WIDTH="12" HEIGHT="12 " ALIGN="BOTTOM" ALT="checked"></center></p></td><td align=center><!-- listselection --> </td><td align=center><!-- window --> </td>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?