This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/src/main/java/envoy/client/ui/primary/PrimaryTextArea.java

71 lines
1.7 KiB
Java

package envoy.client.ui.primary;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>PrimaryTextArea.javaEvent.java</strong><br>
* Created: <strong>07.12.2019</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Client v0.2-alpha
*/
public class PrimaryTextArea extends JTextArea {
private static final long serialVersionUID = 0L;
private int arcSize;
/**
* Creates the text area
*
* @param borderSpace the space between components
* @since Envoy 0.2-alpha
*/
public PrimaryTextArea(int borderSpace) { this(6, borderSpace); }
/**
* Creates the text area
*
* @param arcSize is the diameter of the arc at the four corners.
* @param borderSpace is the insets of the border on all four sides.
* @since Envoy 0.2-alpha
*/
public PrimaryTextArea(int arcSize, int borderSpace) {
super();
setWrapStyleWord(true);
setLineWrap(true);
setBorder(null);
setFont(new Font("Arial", Font.PLAIN, 17));
setBorder(new EmptyBorder(borderSpace, borderSpace, borderSpace, borderSpace));
setOpaque(false);
this.arcSize = arcSize;
}
/**
* {@inheritDoc}
*/
@Override
protected void paintComponent(Graphics g) {
g.setColor(getBackground());
g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize);
super.paintComponent(g);
}
/**
* @return the arcSize - the diameter of the arc at the four corners.
* @since Envoy 0.2-alpha
*/
public int getArcSize() { return arcSize; }
/**
* @param arcSize the arcSize to set
* @since Envoy 0.2-alpha
*/
public void setArcSize(int arcSize) { this.arcSize = arcSize; }
}