Synthetica JButton Margins

667 views Asked by At

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;

enter image description here

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,

2

There are 2 answers

3
trashgod On BEST ANSWER

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.

0
patois50 On

I tried to get the Synthetica L&F to have a look but seems as though you have to create an account which I did not want to do. Anyways, a quick look around the website and I found a page which indicates how you can see and configure some of the values set in the L&F. Might be worth having a look there.

http://www.jyloo.com/synthetica/customize/