mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 23:37:13 -06:00
CheckBox and RadioButton: use Component.focusWidth in icons
This commit is contained in:
@@ -36,6 +36,9 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
public class FlatCheckBoxIcon
|
public class FlatCheckBoxIcon
|
||||||
implements Icon, UIResource
|
implements Icon, UIResource
|
||||||
{
|
{
|
||||||
|
protected final int focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||||
|
protected final int iconSize = 15 + (focusWidth * 2);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintIcon( Component c, Graphics g, int x, int y ) {
|
public void paintIcon( Component c, Graphics g, int x, int y ) {
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
Graphics2D g2 = (Graphics2D) g.create();
|
||||||
@@ -82,33 +85,36 @@ public class FlatCheckBoxIcon
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void paintFocusBorder( Graphics2D g2 ) {
|
protected void paintFocusBorder( Graphics2D g2 ) {
|
||||||
g2.fillRoundRect( 1, 0, 18, 18, 8, 8 );
|
g2.fillRoundRect( 1, 0, iconSize - 1, iconSize - 1, 8, 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintBorder( Graphics2D g2 ) {
|
protected void paintBorder( Graphics2D g2 ) {
|
||||||
g2.fillRoundRect( 3, 2, 14, 14, 4, 4 );
|
g2.fillRoundRect( focusWidth + 1, focusWidth, 14, 14, 4, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintBackground( Graphics2D g2 ) {
|
protected void paintBackground( Graphics2D g2 ) {
|
||||||
g2.fillRoundRect( 4, 3, 12, 12, 4, 4 );
|
g2.fillRoundRect( focusWidth + 2, focusWidth + 1, 12, 12, 4, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintCheckmark( Graphics2D g2 ) {
|
protected void paintCheckmark( Graphics2D g2 ) {
|
||||||
g2.setStroke( new BasicStroke( 1.9f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );
|
|
||||||
Path2D.Float path = new Path2D.Float();
|
Path2D.Float path = new Path2D.Float();
|
||||||
path.moveTo( 6.5f, 9.5f );
|
path.moveTo( 4.5f, 7.5f );
|
||||||
path.lineTo( 8.6f, 12f );
|
path.lineTo( 6.6f, 10f );
|
||||||
path.lineTo( 13.25f, 5.5f );
|
path.lineTo( 11.25f, 3.5f );
|
||||||
|
|
||||||
|
g2.translate( focusWidth, focusWidth );
|
||||||
|
g2.setStroke( new BasicStroke( 1.9f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) );
|
||||||
g2.draw( path );
|
g2.draw( path );
|
||||||
|
g2.translate( -focusWidth, -focusWidth );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconWidth() {
|
public int getIconWidth() {
|
||||||
return scale( 19 );
|
return scale( iconSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconHeight() {
|
public int getIconHeight() {
|
||||||
return scale( 19 );
|
return scale( iconSize );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,21 +28,21 @@ public class FlatRadioButtonIcon
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void paintFocusBorder( Graphics2D g2 ) {
|
protected void paintFocusBorder( Graphics2D g2 ) {
|
||||||
g2.fillOval( 0, 0, 19, 19 );
|
g2.fillOval( 0, 0, iconSize, iconSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBorder( Graphics2D g2 ) {
|
protected void paintBorder( Graphics2D g2 ) {
|
||||||
g2.fillOval( 2, 2, 15, 15 );
|
g2.fillOval( focusWidth, focusWidth, 15, 15 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBackground( Graphics2D g2 ) {
|
protected void paintBackground( Graphics2D g2 ) {
|
||||||
g2.fillOval( 3, 3, 13, 13 );
|
g2.fillOval( focusWidth + 1, focusWidth + 1, 13, 13 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintCheckmark( Graphics2D g2 ) {
|
protected void paintCheckmark( Graphics2D g2 ) {
|
||||||
g2.fillOval( 7, 7, 5, 5 );
|
g2.fillOval( focusWidth + 5, focusWidth + 5, 5, 5 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user