Example usage for javax.swing.plaf.basic BasicTextAreaUI BasicTextAreaUI

List of usage examples for javax.swing.plaf.basic BasicTextAreaUI BasicTextAreaUI

Introduction

In this page you can find the example usage for javax.swing.plaf.basic BasicTextAreaUI BasicTextAreaUI.

Prototype

public BasicTextAreaUI() 

Source Link

Document

Constructs a new BasicTextAreaUI object.

Usage

From source file:no.java.swing.SelectableLabel.java

public SelectableLabel(String text, boolean multiline) {
    Border border = UIManager.getBorder("Label.border");
    setBorder(border != null ? border : Borders.EMPTY_BORDER);
    setLayout(new BorderLayout());
    if (multiline) {
        JTextArea area = new JTextArea(1, 0) {
            @Override//from   w  ww. j av a  2s .  c om
            public void updateUI() {
                setUI(new BasicTextAreaUI());
                invalidate();
            }
        };
        area.setWrapStyleWord(true);
        area.setLineWrap(true);
        textComponent = area;
    } else {
        textComponent = new JTextField() {
            @Override
            public void updateUI() {
                setUI(new BasicTextFieldUI());
                invalidate();
            }
        };
    }
    textComponent.setOpaque(false);
    textComponent.setBackground(new Color(0, true));
    textComponent.setEditable(false);
    textComponent.setDropTarget(null);
    textComponent.setBorder(Borders.EMPTY_BORDER);
    add(textComponent);
    if (!StringUtils.isBlank(text)) {
        setText(text);
    }
}