Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Color;

import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;

public class Main {
    public static void main(String[] argv) throws Exception {
        JSpinner spinner = new JSpinner();

        // Disable keyboard edits in the spinner
        JFormattedTextField tf = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
        tf.setEditable(false);
        tf.setBackground(Color.white);

        // The value of the spinner can still be programmatically changed
        spinner.setValue(new Integer(100));
    }
}