JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.34k stars 266 forks source link

Checkbox default icon : make the border width customizable #508

Closed AurelienL91 closed 2 years ago

AurelienL91 commented 2 years ago

Hello,

In the FlatCheckBoxIcon class, would it be possible to make the border width customizable ?

This might be done by adding a "thickness" field to the paintBorder() method, with a default value of 1, and a setter to this new field.

The code would be something like :

int thickness = 1; <...> protected void paintBorder( Component c, Graphics2D g ) { int arcwh = arc; g.fillRoundRect(2-this.thickness, 1-this.thickness, 12+2*this.thickness, 12+2*this.thickness, arcwh, arcwh ); }

Note : I currently use the version 1.6.1 of FlatLaf, but I checked on the master branch and the FlatCheckBoxIcon.paintBorder() method was not modified this way

DevCharly commented 2 years ago

In FlatLaf 2.0 (and later) you can change the border thickness. See PR #414 and https://www.formdev.com/flatlaf/components/icons/ E.g.

UIManager.put( "CheckBox.icon.borderWidth", 2 );
or
UIManager.put( "CheckBox.icon.borderWidth", 1.5f );

If you need a solution for FlatLaf 1.6.1, then create a subclass of FlatCheckBoxIcon and install that subclass with:

UIManager.put( "CheckBox.icon", new MyFlatCheckBoxIcon() );