JFormDesigner / FlatLaf

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

Button Group #635

Open ebourg opened 1 year ago

ebourg commented 1 year ago

Several UI toolkits have a concept of button groups, where adjacent buttons share their borders, for example:

It looks like this: image

It would be great to have something similar in FlatLaf. I'm not sure how this could be implemented though. Maybe supporting rounded corners only on the left or on the right would be a first step, and then the layout could be configured such that the inner borders are superposed.

gk-brown commented 1 year ago

Would something like this (using JToggleButton and ButtonGroup) work?

button-group

Source code is available here. This example uses a lightweight library I wrote to simplify layout, but that's not strictly necessary. The icons are instances of FlatLaf's FlatSVGIcon class, and the border is an instance of FlatLineBorder. The buttons are styled using the "toolBarButton" client property.