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

How could I create badge icon by using Button? #679

Open
zjcscut opened this issue May 9, 2023 · 1 comment
Open

How could I create badge icon by using Button? #679

zjcscut opened this issue May 9, 2023 · 1 comment

Comments

@zjcscut
Copy link

zjcscut commented May 9, 2023

like this,how could I change the border color for any button
image

@daviddev16
Copy link

daviddev16 commented Jun 22, 2023

Hi @zjcscut ! Hope you are doing well!

One thing that you could do is create a custom component with a custom button ui using BasicButtonUI. This example uses Flatlaf version 3.1.1.

image

In this case, a made a class called BadgedLabel that extends JPanel with a JButton and a JLabel in constructor constrained with the BoxLayout. The BadgedLabel class will be used as a model object in CustomList that extends JList and implements ListCellRenderer<BadgedLabel>. The BadgedLabel also contains the BadgeButtonUI which will be used to customize the JButton UI.

image

Inside CustomList we can create the BadgedLabel object and add to the JList custom model.

I hope I was able to help in someway!

code-example.zip

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