forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.1 KiB
72 lines
2.1 KiB
package com.fanruan.api.design.ui.component; |
|
|
|
import com.fanruan.api.design.macro.UIConstants; |
|
|
|
import javax.swing.*; |
|
import javax.swing.border.TitledBorder; |
|
import java.awt.*; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-08-30 |
|
* 带标题的边框 |
|
*/ |
|
public class UITitledBorder extends TitledBorder { |
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
public static UITitledBorder createBorderWithTitle(String title) { |
|
return new UITitledBorder(title); |
|
} |
|
|
|
public static UITitledBorder createBorderWithTitle(String title, int roundedCorner) { |
|
return new UITitledBorder(title, roundedCorner); |
|
} |
|
|
|
private UITitledBorder(String title) { |
|
super( |
|
BorderFactory.createCompoundBorder( |
|
BorderFactory.createEmptyBorder( |
|
0, |
|
0, |
|
5, |
|
0), |
|
new UIRoundedBorder( |
|
UIConstants.TITLED_BORDER_COLOR, |
|
1, |
|
10) |
|
), |
|
title, |
|
TitledBorder.LEADING, |
|
TitledBorder.TOP, |
|
null, |
|
new Color(1, 159, 222) |
|
); |
|
} |
|
|
|
/** |
|
* @param title title |
|
* @param roundedCorner corner width 圆弧宽度,即圆角直径 |
|
*/ |
|
private UITitledBorder(String title, int roundedCorner) { |
|
super( |
|
BorderFactory.createCompoundBorder( |
|
BorderFactory.createEmptyBorder( |
|
0, |
|
0, |
|
5, |
|
0), |
|
new UIRoundedBorder( |
|
UIConstants.TITLED_BORDER_COLOR, |
|
1, |
|
roundedCorner) |
|
), |
|
title, |
|
TitledBorder.LEADING, |
|
TitledBorder.TOP, |
|
null, |
|
new Color(1, 159, 222) |
|
); |
|
} |
|
}
|
|
|