|
@@ -0,0 +1,40 @@
|
|
|
|
|
+package net.ranides.assira.ui.components;
|
|
|
|
|
+
|
|
|
|
|
+import javax.swing.border.AbstractBorder;
|
|
|
|
|
+import java.awt.*;
|
|
|
|
|
+
|
|
|
|
|
+public class CustomRoundedBorder extends AbstractBorder {
|
|
|
|
|
+ private final BasicStroke stroke;
|
|
|
|
|
+ private final Color color;
|
|
|
|
|
+ private final int radius;
|
|
|
|
|
+
|
|
|
|
|
+ public CustomRoundedBorder(int size, Color color, int radius) {
|
|
|
|
|
+ this.stroke = new BasicStroke(size);
|
|
|
|
|
+ this.radius = radius;
|
|
|
|
|
+ this.color = color;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
|
|
|
|
+ super.paintBorder(c, g, x, y, width, height);
|
|
|
|
|
+
|
|
|
|
|
+ Graphics2D g2 = (Graphics2D) g.create();
|
|
|
|
|
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
|
|
+ g2.setColor(color);
|
|
|
|
|
+ g2.setStroke(stroke);
|
|
|
|
|
+ int size = (int)Math.ceil(stroke.getLineWidth());
|
|
|
|
|
+ g2.drawRoundRect(x, y, width-size, height-size, radius, radius);
|
|
|
|
|
+
|
|
|
|
|
+ g2.dispose();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Insets getBorderInsets(Component c, Insets insets) {
|
|
|
|
|
+ int size = (int)Math.ceil(stroke.getLineWidth());
|
|
|
|
|
+ insets.set(size, size, size, size);
|
|
|
|
|
+ return insets;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean isBorderOpaque() {return true;}
|
|
|
|
|
+
|
|
|
|
|
+}
|