How to change the default selection on JSpinner?

I have a problem with JSpinner . I use the time format in the counter "hh:mm:ss,msmsms" . When I go to increase the time with the mouse without any choice in the counter format, I do not select any part of the time, for example hours, minutes, seconds or milliseconds, it always increases the default hours in hours.

I want to give this default choice for the second tool, when I am going to increase or decrease the time with the mouse, it works in the second part.

eg.

 01:05:08,102 

After you press the counter status, the following time will appear.

 01:05:09,102 

This is the code:

 Start_time_jSpinner = new javax.swing.JSpinner(); Start_time_jSpinner.setModel(new SpinnerDateModel()); Start_time_jSpinner.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); Start_time_jSpinner.setEditor(new JSpinner.DateEditor(Start_time_jSpinner, "HH:mm:ss,SSS")); 
+4
source share
1 answer

Even if the hour field is selected, the value will increase / decrease by a second after the up / down arrow.

 import java.util.Date; import javax.swing.*; public class SecondIncrement { SecondIncrement() { JSpinner spinner = new JSpinner(); SpinnerDateModel dateModel = new SpinnerDateModel(){ @Override public Object getNextValue() { Date date = this.getDate(); long millis = date.getTime(); return new Date(millis+1000); } @Override public Object getPreviousValue() { Date date = this.getDate(); long millis = date.getTime(); return new Date(millis-1000); } }; spinner.setModel(dateModel); spinner.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); spinner.setEditor(new JSpinner.DateEditor(spinner, "HH:mm:ss,SSS")); JOptionPane.showMessageDialog(null, spinner); } public static void main(String[] args) throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { new SecondIncrement(); } }); } } 
+4
source