I have 2 JSpinners in my application, I installed the model, editor, number format for both of them. However, when I launch the application, the second does not show the fractional part initially. It looks like a focus problem.
So, first one is intialized 0.0, and the second is initialized as 0; I want the second to be the first. Did I miss a step here? Here is my code below.

Here is my code
import java.text.DecimalFormat;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
public class NewJFrame extends javax.swing.JFrame {
private final JSpinner.NumberEditor editor;
DecimalFormat format , format2 ;
private final JSpinner.NumberEditor editor1;
public NewJFrame() {
initComponents();
SpinnerNumberModel model1 = new SpinnerNumberModel(0.0,-1000.0 ,1000.0,0.1);
this.jSpinner1.setModel(model1);
editor = new JSpinner.NumberEditor(this.jSpinner1);
this.jSpinner1.setEditor(editor);
format = editor.getFormat();
format.setMinimumFractionDigits(1);
SpinnerNumberModel model2 = new SpinnerNumberModel(0.0,-1000.0 ,1000.0,0.1);
this.jSpinner2.setModel(model2);
editor1 = new JSpinner.NumberEditor(this.jSpinner2);
this.jSpinner2.setEditor(editor1);
format2 = editor1.getFormat();
format2.setMinimumFractionDigits(1);
}
@SuppressWarnings("unchecked")
private void initComponents() {
jSpinner1 = new javax.swing.JSpinner();
jSpinner2 = new javax.swing.JSpinner();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
formMouseMoved(evt);
}
});
jSpinner1.setFocusable(false);
jSpinner1.setOpaque(false);
jSpinner1.setRequestFocusEnabled(false);
jSpinner2.setFocusable(false);
jSpinner2.setOpaque(false);
jSpinner2.setRequestFocusEnabled(false);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(41, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(31, Short.MAX_VALUE))
);
pack();
}
private void formMouseMoved(java.awt.event.MouseEvent evt) {
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
private javax.swing.JSpinner jSpinner1;
private javax.swing.JSpinner jSpinner2;
}