Tuesday, August 31, 2010

Article | Disable Keyboard Editing in JSpinner

A simple example on JSpinner. In this example, the editing mode is disabled using setEditable() method


  1. import javax.swing.*;

  2. import java.awt.*;

  3. public class Disablekeyboard{

  4. public static void main(String[] args){

  5. JFrame frm = new JFrame("Disable Keyboard Editing Example");

  6. JSpinner spinner = new JSpinner();

  7. JFormattedTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor())

  8. .getTextField();

  9. tf.setEditable(false);

  10. spinner.setValue(new Integer(100));

  11. JPanel panel = new JPanel();

  12. panel.add(spinner);

  13. frm.add(panel, BorderLayout.NORTH);

  14. frm.setSize(350, 350);

  15. frm.setVisible(true);

  16. frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  17. }

  18. }

Loading...

Comments :

0 comments to “ Disable Keyboard Editing in JSpinner ”

Top Views

BloggerTipsTemplates

CHICKLETS

Enter your email address:

Delivered by FeedBurner

Followers