Example usage for javax.swing JFormattedTextField setMargin

List of usage examples for javax.swing JFormattedTextField setMargin

Introduction

In this page you can find the example usage for javax.swing JFormattedTextField setMargin.

Prototype

@BeanProperty(description = "desired space between the border and text area")
public void setMargin(Insets m) 

Source Link

Document

Sets margin space between the text component's border and its text.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    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;//  w  w w.  ja  va 2s  .co  m
    int left = 2;
    int bottom = 0;
    int right = 2;
    Insets insets = new Insets(top, left, bottom, right);
    tf.setMargin(insets);

}