A simple example on JSpinner. In this example, the editing mode is disabled using setEditable() method
import javax.swing.*;
import java.awt.*;
public class Disablekeyboard{
public static void main(String[] args){
JFrame frm = new JFrame("Disable Keyboard Editing Example");
JSpinner spinner = new JSpinner();
JFormattedTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor())
.getTextField();
tf.setEditable(false);
spinner.setValue(new Integer(100));
JPanel panel = new JPanel();
panel.add(spinner);
frm.add(panel, BorderLayout.NORTH);
frm.setSize(350, 350);
frm.setVisible(true);
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Loading...
|
Comments :
Post a Comment