Setting the Margin Space on a JSpinner Component
import java.awt.Insets;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
public class Main {
public static void main(String[] argv) throws Exception {
JSpinner spinner = new JSpinner();
// Get the text field
JFormattedTextField tf = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
// Set the margin (add two spaces to the left and right side of the value)
int top = 0;
int left = 2;
int bottom = 0;
int right = 2;
Insets insets = new Insets(top, left, bottom, right);
tf.setMargin(insets);
}
}
Related examples in the same category