Java JTextComponent setTextComponentMargins(JTextComponent component)

Here you can find the source of setTextComponentMargins(JTextComponent component)

Description

set Text Component Margins

License

Open Source License

Declaration

public static void setTextComponentMargins(JTextComponent component) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Insets;

import javax.swing.text.JTextComponent;

public class Main {
    private static final int DEFAULT_TEXT_COMPONENT_VERTICAL_MARGIN = 2;
    private static final int DEFAULT_TEXT_COMPONENT_HORIZONAL_MARGIN = 4;

    public static void setTextComponentMargins(JTextComponent component) {
        setTextComponentMargins(component, DEFAULT_TEXT_COMPONENT_VERTICAL_MARGIN,
                DEFAULT_TEXT_COMPONENT_HORIZONAL_MARGIN);
    }//from w ww  .ja  v  a 2 s  .c  om

    public static void setTextComponentMargins(JTextComponent component, int vertical, int horizontal) {
        Insets margins = component.getMargin();
        margins.set(Math.max(vertical, margins.top), Math.max(horizontal, margins.left),
                Math.max(vertical, margins.bottom), Math.max(horizontal, margins.right));
        component.setMargin(margins);
    }
}

Related

  1. setErrorBackground(JTextComponent comp)
  2. setMandatoryBackground(JTextComponent comp)
  3. setMandatoryBorder(JTextComponent comp)
  4. setMandatoryBorder(JTextComponent comp)
  5. setText(JTextComponent textComp, String text)
  6. setTextComponentTransparent( JTextComponent paramJTextComponent)
  7. setTextComponentTransparent( JTextComponent textComponent)
  8. setTextComponentTransparent( JTextComponent textComponent)
  9. setTextComponetIntegerValid(final JTextComponent c)