问JSpinner:当我使用"getValue()“方法时,它会返回1974年1月1日的日期EN我遇到了Java JSpinner的问...
} return spinner.getValue(); 有关使用微调器的信息和示例,请参阅“Java教程”中的 How to Use Spinners部分。 警告: Swing不是线程安全的。 有关更多信息,请参阅Swing's Threading Policy。 警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储...
try { spinner.commitEdit(); } catch (ParseException pe) { // Edited value is invalid, spinner.getValue() will return // the last valid value, you could revert the spinner to show that: JComponent editor = spinner.getEditor(); if (editor instanceof DefaultEditor) { ((DefaultEditor)editor...
To make sure the model has the same value as the editor use the commitEdit method, eg: try { spinner.commitEdit(); } catch (ParseException pe) { // Edited value is invalid, spinner.getValue() will return // the last valid value, you could revert the spinner to show that: J...
String value = (String)spinner.getValue(); // Update the displayed color setColor(value); } // Updates the displayed color to 'colorName' which must be one // of the predefined colors in java.awt.Color. public void setColor(String colorName) { ...
=MouseWheelEvent.WHEEL_UNIT_SCROLL){return;}double value=(Double)spinner.getValue();value-=mwe....
public Object getValue(); public void setValue(Object); public Object getNextValue(); public Object getPreviousValue(); // Listeners public void addChangeListener(ChangeListener); public void removeChangeListener(ChangeListener); } SpinnerModel中的六个方法直接绘制了JSpinner,而JSpinner的方法间接调用...
spinner.setValue(new Integer(100)); public class SpinnerListener implements ChangeListener { public void stateChanged(ChangeEvent evt) { JSpinner spinner = (JSpinner)evt.getSource(); // Get the new value Object value = spinner.getValue(); ...
String selectedDay = spinner.getModel().getValue().toString(); String selectedDay = spinner.getValue().toString(); スピナーの値の設定は似ています。モデルがサポートしないオブジェクトに SpinnerModel の値を設定しようとすると、IllegalArgumentException がスローされます。日付と数値は、ス...
public void stateChanged(ChangeEvent evt) { JSpinner spinner = (JSpinner)evt.getSource(); // Get the new value Object value = spinner.getValue(); } } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. ...