All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alee.laf.text.AbstractTextFieldPainter Maven / Gradle / Ivy

Go to download

WebLaf is a Java Swing Look and Feel and extended components library for cross-platform applications

There is a newer version: 2.2.1
Show newest version
package com.alee.laf.text;

import com.alee.laf.text.AbstractTextEditorPainter;
import com.alee.laf.text.IAbstractTextFieldPainter;
import com.alee.laf.text.TextFieldLayout;
import com.alee.painter.decoration.IDecoration;

import javax.swing.*;
import javax.swing.plaf.basic.BasicTextUI;
import javax.swing.text.JTextComponent;
import java.awt.*;

/**
 * @author Alexandr Zernov
 * @author Mikle Garin
 */

public abstract class AbstractTextFieldPainter>
        extends AbstractTextEditorPainter implements IAbstractTextFieldPainter, SwingConstants
{
    @Override
    public void install ( final E c, final U ui )
    {
        super.install ( c, ui );

        // Installing custom layout for leading/trailing components
        component.setLayout ( new TextFieldLayout () );
    }

    @Override
    public void uninstall ( final E c, final U ui )
    {
        // Uninstalling custom layout for leading/trailing components
        component.setLayout ( null );

        super.uninstall ( c, ui );
    }

    @Override
    public Insets getBorders ()
    {
        final Insets base = super.getBorders ();
        final Component lc = getLeadingComponent ();
        final Component tc = getTrailingComponent ();
        if ( lc != null || tc != null )
        {
            return i ( base, 0, lc != null ? lc.getPreferredSize ().width : 0, 0, tc != null ? tc.getPreferredSize ().width : 0 );
        }
        else
        {
            return base;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy