![]() |
The Java Developers Almanac 1.4 |
|
e788. Disabling Keyboard Editing in a JSpinner Component // Create a nummber spinner
JSpinner spinner = new JSpinner();
// Disable keyboard edits in the spinner
JFormattedTextField tf =
((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();
tf.setEditable(false);
// The previous call sets the background to a disabled
// color (usually gray). To change this disabled color,
// reset the background color.
tf.setBackground(Color.white);
// The value of the spinner can still be programmatically changed
spinner.setValue(new Integer(100));
e787. Creating an Hour JSpinner Component e789. Limiting the Values in a Number JSpinner Component e790. Setting the Margin Space on a JSpinner Component e791. Customizing the Editor in a JSpinner Component e792. Creating a SpinnerListModel That Loops Through Its Values e793. Listening for Changes to the Value in a JSpinner Component © 2002 Addison-Wesley. |