The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing  [141 examples] > JSpinner  [8 examples]

e790. Setting the Margin Space on a JSpinner Component

    // Create a number spinner
    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
e786. Creating a JSpinner Component
e787. Creating an Hour JSpinner Component
e788. Disabling Keyboard Editing in a JSpinner Component
e789. Limiting the Values in a Number 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

See also: Actions    JButton    JCheckBox    JComboBox    JDesktop and JInternalFrame    JFrame, JWindow, JDialog    JLabel    JList    JProgressBar    JRadioButton    JScrollPane    JSlider    JSplitPane    JTabbedPane    JToolBar    Keystrokes and Input Maps    Layout    Look and Feel    Menus    Progress Monitor    The Screen    Tool Tips    UI Default Values   


© 2002 Addison-Wesley.