So, I have a Calendar solution for my employers where I am using a custom look and feel (Synthetica) and each cell in the table holds a JPanel
with a list of buttons and a PAGE_AXIS
BoxLayout
. I am trying to reduce the gaps between each button so that they abut each other, and I've tried setting the borders to null except that destroys the button appearance. I have used the following (as recommended by Oracle to view the actual size of the components) code;
setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.red),
getBorder()));
And this is what I get;
Setting the margin does not work with whatever border version the buttons are using. So, is there any way to find the current border that it's using? So that I can set that border's insets manually, or something like that. Basically, I need the buttons to abut each other. Any ideas?
Clarification: I want the button's themselves to stay the same size, but I want the white space around them (highlighted inside of the red borders) to be gone,
Several possibilities should be considered:
Manipulate the button's bound properties:
setBorderPainted(false)
, et al., as suggested here.See if a suitable
sizeVariant
is available, as shown here.Use a custom UI delegate based on
BasicButtonUI
, as shown here and here.