📄 timer.html
字号:
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="Timer(int, java.awt.event.ActionListener)"><!-- --></A><H3>Timer</H3><PRE>public <B>Timer</B>(int delay, <A HREF="../../java/awt/event/ActionListener.html">ActionListener</A> listener)</PRE><DL><DD>Creates a Timer that will notify its listeners every <i>delay</i> milliseconds.<DD><DL><DT><B>Parameters:</B><DD><CODE>delay</CODE> - The number of milliseconds between listener notification<DD><CODE>listener</CODE> - An initial listener<DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setInitialDelay(int)"><CODE>setInitialDelay(int)</CODE></A>, <A HREF="../../javax/swing/Timer.html#setRepeats(boolean)"><CODE>setRepeats(boolean)</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="addActionListener(java.awt.event.ActionListener)"><!-- --></A><H3>addActionListener</H3><PRE>public void <B>addActionListener</B>(<A HREF="../../java/awt/event/ActionListener.html">ActionListener</A> listener)</PRE><DL><DD>Adds an actionListener to the Timer<DD><DL></DL></DD></DL><HR><A NAME="removeActionListener(java.awt.event.ActionListener)"><!-- --></A><H3>removeActionListener</H3><PRE>public void <B>removeActionListener</B>(<A HREF="../../java/awt/event/ActionListener.html">ActionListener</A> listener)</PRE><DL><DD>Removes an ActionListener from the Timer.<DD><DL></DL></DD></DL><HR><A NAME="fireActionPerformed(java.awt.event.ActionEvent)"><!-- --></A><H3>fireActionPerformed</H3><PRE>protected void <B>fireActionPerformed</B>(<A HREF="../../java/awt/event/ActionEvent.html">ActionEvent</A> e)</PRE><DL><DD>Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/event/EventListenerList.html"><CODE>EventListenerList</CODE></A></DL></DD></DL><HR><A NAME="getListeners(java.lang.Class)"><!-- --></A><H3>getListeners</H3><PRE>public <A HREF="../../java/util/EventListener.html">EventListener</A>[] <B>getListeners</B>(<A HREF="../../java/lang/Class.html">Class</A> listenerType)</PRE><DL><DD>Return an array of all the listeners of the given type that were added to this timer.<DD><DL></DL></DD><DD><DL><DT><B>Since: </B><DD>1.3</DD></DL></DD></DL><HR><A NAME="setLogTimers(boolean)"><!-- --></A><H3>setLogTimers</H3><PRE>public static void <B>setLogTimers</B>(boolean flag)</PRE><DL><DD>Enables or disables the timer log. When enabled, a message is posted to System.out whenever the timer goes off.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>flag</CODE> - true to enable logging<DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#getLogTimers()"><CODE>getLogTimers()</CODE></A></DL></DD></DL><HR><A NAME="getLogTimers()"><!-- --></A><H3>getLogTimers</H3><PRE>public static boolean <B>getLogTimers</B>()</PRE><DL><DD>Returns true if logging is enabled.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if logging is enabled<DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setLogTimers(boolean)"><CODE>setLogTimers(boolean)</CODE></A></DL></DD></DL><HR><A NAME="setDelay(int)"><!-- --></A><H3>setDelay</H3><PRE>public void <B>setDelay</B>(int delay)</PRE><DL><DD>Sets the Timer's delay, the number of milliseconds between successive <b>actionPerfomed()</b> messages to its listeners<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setInitialDelay(int)"><CODE>setInitialDelay(int)</CODE></A></DL></DD></DL><HR><A NAME="getDelay()"><!-- --></A><H3>getDelay</H3><PRE>public int <B>getDelay</B>()</PRE><DL><DD>Returns the Timer's delay.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setDelay(int)"><CODE>setDelay(int)</CODE></A></DL></DD></DL><HR><A NAME="setInitialDelay(int)"><!-- --></A><H3>setInitialDelay</H3><PRE>public void <B>setInitialDelay</B>(int initialDelay)</PRE><DL><DD>Sets the Timer's initial delay. This will be used for the first "ringing" of the Timer only. Subsequent ringings will be spaced using the delay property.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setDelay(int)"><CODE>setDelay(int)</CODE></A></DL></DD></DL><HR><A NAME="getInitialDelay()"><!-- --></A><H3>getInitialDelay</H3><PRE>public int <B>getInitialDelay</B>()</PRE><DL><DD>Returns the Timer's initial delay.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setDelay(int)"><CODE>setDelay(int)</CODE></A></DL></DD></DL><HR><A NAME="setRepeats(boolean)"><!-- --></A><H3>setRepeats</H3><PRE>public void <B>setRepeats</B>(boolean flag)</PRE><DL><DD>If <b>flag</b> is <b>false</b>, instructs the Timer to send <b>actionPerformed()</b> to its listeners only once, and then stop.<DD><DL></DL></DD></DL><HR><A NAME="isRepeats()"><!-- --></A><H3>isRepeats</H3><PRE>public boolean <B>isRepeats</B>()</PRE><DL><DD>Returns <b>true</b> if the Timer will send a <b>actionPerformed()</b> message to its listeners multiple times.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setRepeats(boolean)"><CODE>setRepeats(boolean)</CODE></A></DL></DD></DL><HR><A NAME="setCoalesce(boolean)"><!-- --></A><H3>setCoalesce</H3><PRE>public void <B>setCoalesce</B>(boolean flag)</PRE><DL><DD>Sets whether the Timer coalesces multiple pending ActionEvent firings. A busy application may not be able to keep up with a Timer's message generation, causing multiple <b>actionPerformed()</b> message sends to be queued. When processed, the application sends these messages one after the other, causing the Timer's listeners to receive a sequence of <b>actionPerformed()</b> messages with no delay between them. Coalescing avoids this situation by reducing multiple pending messages to a single message send. Timers coalesce their message sends by default.<DD><DL></DL></DD></DL><HR><A NAME="isCoalesce()"><!-- --></A><H3>isCoalesce</H3><PRE>public boolean <B>isCoalesce</B>()</PRE><DL><DD>Returns <b>true</b> if the Timer coalesces multiple pending <b>performCommand()</b> messages.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#setCoalesce(boolean)"><CODE>setCoalesce(boolean)</CODE></A></DL></DD></DL><HR><A NAME="start()"><!-- --></A><H3>start</H3><PRE>public void <B>start</B>()</PRE><DL><DD>Starts the Timer, causing it to send <b>actionPerformed()</b> messages to its listeners.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#stop()"><CODE>stop()</CODE></A></DL></DD></DL><HR><A NAME="isRunning()"><!-- --></A><H3>isRunning</H3><PRE>public boolean <B>isRunning</B>()</PRE><DL><DD>Returns <b>true</b> if the Timer is running.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#start()"><CODE>start()</CODE></A></DL></DD></DL><HR><A NAME="stop()"><!-- --></A><H3>stop</H3><PRE>public void <B>stop</B>()</PRE><DL><DD>Stops a Timer, causing it to stop sending <b>actionPerformed()</b> messages to its Target.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/Timer.html#start()"><CODE>start()</CODE></A></DL></DD></DL><HR><A NAME="restart()"><!-- --></A><H3>restart</H3><PRE>public void <B>restart</B>()</PRE><DL><DD>Restarts a Timer, canceling any pending firings, and causing it to fire with its initial dely.<DD><DL></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Timer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../javax/swing/SwingUtilities.html"><B>PREV CLASS</B></A> <A HREF="../../javax/swing/ToolTipManager.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Timer.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -