Code example for JTextComponent

Methods: getUI

0
//        g.drawRect(x, y, width - 1, height - 1); 
    } 
 
    static int getShrinkageFor(final JTextComponent jc, final int height) {
        if (jc == null) return 0;
        final TextUI ui = jc.getUI();
        if (ui == null) return 0;
        final Dimension size = ui.getPreferredSize(jc);
        if (size == null) return 0;
        final int shrinkage = size.height - height;
        return (shrinkage < 0) ? 0 : (shrinkage > 3) ? 3 : shrinkage;
    } 
 
    // this determines the rect that we should draw inset to our existing bounds 
    protected Insets getSubInsets(final int shrinkage) {
        final Insets insets = sizeVariant.insets;
 
        if (shrinkage > 0) {
            return new InsetsUIResource(insets.top - shrinkage, insets.left, insets.bottom - shrinkage, insets.right);
        }