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

FlatDarkLaf JButton ignores setMargin() #364

Closed
jjazzboss opened this issue Jul 28, 2021 · 5 comments
Closed

FlatDarkLaf JButton ignores setMargin() #364

jjazzboss opened this issue Jul 28, 2021 · 5 comments
Milestone

Comments

@jjazzboss
Copy link

I use FlatDarkLaf on my Netbeans application, thanks for this great L&F, it works very well in general :-)

For some specific dialogs I need "small" OK JButtons. The default left/right margins around the text are too large in this case, and I'd like to change them.

myButton.setMargin() works when using the system L&F, but is ignored when using FlatDarkLaf.

I found the FlatLaf properties "Button.margin", I tried setting myButton.putClientProperty("Button.margin", new Insets(...)) but it is ignored as well.

What could I do ?

Thanks

@Bios-Marcel
Copy link
Contributor

setMargin isn't being ignored:

image

But there's two components to the spacing. One is the margin and one is the insets, which afaik come from the border.

@DevCharly
Copy link
Collaborator

As Marcel sad, margins are not ignored, but your problem is that buttons in FlatLaf have a minimum width of 72px.
You can disable minimum width for a single button:

myButton.putClientProperty( "JComponent.minimumWidth", 0 );

Or for the whole application:

UIManager.put( "Button.minimumWidth", 0 );

@DevCharly
Copy link
Collaborator

This question brings me to the idea to not apply minimum button width if button margins are changed...

@jjazzboss
Copy link
Author

@DevCharly Thanks for the minimumWidth tip!

@DevCharly
Copy link
Collaborator

Starting with FlatLaf 1.5, if button (or text component) margins are modified (JButton.setMargin(...)),
then the minimum width is no longer applied.

@DevCharly DevCharly added this to the 1.5 milestone Aug 2, 2021
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

3 participants