Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button Group #635

Open
ebourg opened this issue Jan 7, 2023 · 2 comments
Open

Button Group #635

ebourg opened this issue Jan 7, 2023 · 2 comments

Comments

@ebourg
Copy link
Contributor

ebourg commented Jan 7, 2023

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
Copy link

gk-brown commented Aug 11, 2023

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.

@gk-brown
Copy link

It seems that FlatLaf actually supports this natively, at least for toolbars. The following code produces an effect similar to what you describe above:

var toggleButton1 = new JToggleButton("foo");
var toggleButton2 = new JToggleButton("bar");

var buttonGroup = new ButtonGroup();

toolBar.add(toggleButton1);
toolBar.add(toggleButton2);

buttonGroup.add(toggleButton1);
buttonGroup.add(toggleButton2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants