📄 spinner.html
字号:
</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/JSpinner.html#JSpinner()">JSpinner()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#JSpinner(javax.swing.SpinnerModel)">JSpinner(SpinnerModel)</a> </td> <td>Create a new <code>JSpinner</code>. The no-argument constructor creates a spinner with an integer <code>SpinnerNumberModel</code> with an initial value of 0 and no minimum or maximum limits. The optional parameter on the second constructor allows you to specify your own <code>SpinnerModel</code>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#setValue(java.lang.Object)">void setValue(java.lang.Object)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#getValue()">Object getValue()</a> </td> <td>Set or get the currently displayed element of the sequence. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#getNextValue()">Object getNextValue()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#getPreviousValue()">Object getPreviousValue()</a> </td> <td>Get the object in the sequence that comes after or before the object returned by <code>getValue</code>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#getModel()">SpinnerModel getModel()</a><br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#setModel(javax.swing.SpinnerModel)">void setModel(SpinnerModel)</a> </td> <td>Get or set the spinner's model. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#getEditor()">JComponent getEditor()</a><br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#setEditor(javax.swing.JComponent)">void setEditor(JComponent)</a> </td> <td>Get or set the spinner's editor, which is often an object of type <code>JSpinner.DefaultEditor</code>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.html#createEditor(javax.swing.SpinnerModel)">protected JComponent createEditor(SpinnerModel)</a> </td> <td>Called by the <code>JSpinner</code> constructors to create the spinner's editor. Override this method to associate an editor with a particular type of model. </td> </tr></table><p><table border=1><caption><a name="editorapi">Useful Editor Constructors and Methods</a></caption><tr><th align=left>Constructor or 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/JSpinner.NumberEditor.html#JSpinner.NumberEditor(javax.swing.JSpinner, java.lang.String)">JSpinner.NumberEditor(JSpinner, String)</a> </td> <td>Create a <code>JSpinner.NumberEditor</code> instance that displays and allows editing of the number value of the specified spinner. The string argument specifies the format to use to display the number. See the API documentation for<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html">DecimalFormat</a> for information about decimal format strings. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.DateEditor.html#JSpinner.DateEditor(javax.swing.JSpinner, java.lang.String)">JSpinner.DateEditor(JSpinner, String)</a> </td> <td>Create a <code>JSpinner.DateEditor</code> instance that displays and allows editing of the <code>Date</code> value of the specified spinner. The string argument specifies the format to use to display the date. See the API documentation for<a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a> for information about date format strings. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JSpinner.DefaultEditor.html#getTextField()">JFormattedTextField getTextField()</a><br><em>(defined in <code>JSpinner.DefaultEditor</code>)</em> </td> <td>Get the formatted text field that provides the main GUI forthis editor. </td> </tr></table><p><table border=1><caption><a name="listapi">SpinnerListModel Methods</a></caption><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/SpinnerListModel.html#setList(java.util.List)">void setList(List)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerListModel.html#getList()">List getList()</a> </td> <td>Set or get the <code>List</code> that defines the sequence for this model. </td> </tr></table><p><table border=1><caption><a name="dateapi">SpinnerDateModel Methods</a></caption><tr><th align=left>Method</th><th align=left>Purpose</th></tr> <tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#setValue(java.lang.Object)">void setValue(Object)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#getDate()">Date getDate()</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#getValue()">Object getValue()</a> </td> <td>Set or get the current <code>Date</code> for this sequence. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#setStart(java.lang.Comparable)">void setStart(Comparable)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#getStart()">Comparable getStart()</a> </td> <td>Set or get the first <code>Date</code> in this sequence. Use <code>null</code> to specify that the spinner has no lower limit. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#setEnd(java.lang.Comparable)">void setEnd(Comparable)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#getEnd()">Comparable getEnd()</a> </td> <td>Set or get the last <code>Date</code> in this sequence. Use <code>null</code> to specify that the spinner has no upper limit. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#setCalendarField(int)">void setCalendarField(int)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerDateModel.html#getCalendarField()">int getCalendarField()</a> </td> <td>Set or get the size of the date value increment used by the <code>getNextValue</code> and <code>getPreviousValue</code> methods. This property is <em>not</em> used when the user explicitly increases or decreases the value; instead, the selected part of the formatted text field is incremented or decremented. The specified parameter must be one of the following constants, defined in <code>Calendar</code>: <code>ERA</code>, <code>YEAR</code>, <code>MONTH</code>, <code>WEEK_OF_YEAR</code>, <code>WEEK_OF_MONTH</code>, <code>DAY_OF_MONTH</code>, <code>DAY_OF_YEAR</code>, <code>DAY_OF_WEEK</code>, <code>DAY_OF_WEEK_IN_MONTH</code>, <code>AM_PM</code>, <code>HOUR_OF_DAY</code>, <code>MINUTE</code>, <code>SECOND</code>, <code>MILLISECOND</code>. </td> </tr></table><p><table border=1><caption><a name="numberapi">SpinnerNumberModel Methods</a></caption><tr><th align=left>Method</th><th align=left>Purpose</th></tr> <tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#setValue(java.lang.Object)">void setValue(Object)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#getNumber()">Number getNumber()</a> </td> <td>Set or get the current value for this sequence. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#setMaximum(java.lang.Comparable)">void setMaximum(Comparable)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#getMaximum()">Comparable getMaximum()</a> </td> <td>Set or get the upper bound for numbers in this sequence. If the maximum is <code>null</code>, there is no upper bound. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#setMinimum(java.lang.Comparable)">void setMinimum(Comparable)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#getMinimum()">Comparable getMinimum()</a> </td> <td>Set or get the lower bound for numbers in this sequence. If the minimum is <code>null</code>, there is no lower bound. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#setStepSize(java.lang.Number)">void setStepSize(Number)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SpinnerNumberModel.html#getStepSize()">Number getStepSize()</a> </td> <td>Set or get the increment used by <code>getNextValue</code> and <code>getPreviousValue</code> methods. </td> </tr></table></blockquote><h3><a name="eg">Examples that Use Spinners</a></h3><blockquote>The following examples use spinners.<p><table><tr><th align=left> Example</th><th align=left> Where Described</th><th align=left> Notes</th></tr><tr><td> <a href="examples/index.html#SpinnerDemo"><code>SpinnerDemo</code></a></td><td> This section</td><td> Uses all three standard spinner model classes. Contains the code to use a custom spinner model, but the code is turned off by default.</td></tr><tr><td> <a href="examples/index.html#SpinnerDemo2"><code>SpinnerDemo2</code></a></td><td> This section</td><td> A <code>SpinnerDemo</code> subclass that uses the custom spinner model for its Months spinner.</td></tr><tr><td> <a href="examples/index.html#SpinnerDemo3"><code>SpinnerDemo3</code></a></td><td> This section</td><td> Based on SpinnerDemo, this application shows how to listen for changes in a spinner's value.</td></tr><tr><td> <a href="examples/index.html#SpinnerDemo4"><code>SpinnerDemo4</code></a></td><td> This section</td><td> Implements a custom model and a custom editor for a spinner that displays shades of gray.</td></tr></table> </blockquote> <div class=NavBit> <a target=_top href=slider.html>« Previous</a> • <a target=_top href=../TOC.html>Trail</a> • <a target=_top href=splitpane.html>Next »</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 Use Sliders <br><b>Next page:</b> How to Use Split Panes </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -