2 Replies Latest reply: Jan 23, 2012 3:44 AM by Kleopatra RSS

    JToggleButton Margins too big in Nimbus LAF - nothing reduces it.

      I'm working on a swing app that is using the Nimbus L&F.

      A number of custom JPanels I've created use a GridLayout with all the grid cells filled with JToggleButtons.

      I set the layout to have 0 for both hgap and vgap.

      When I run the application there is more spacing than I would like between the JToggleButtons. The insets are also larger than I would like.

      I have my own NimbusTheme defined and I tried setting Nimbus defaults using UIManager.put() with different Nimbus properties that look like they would make a difference, such as ToggleButton.contentMargins. (a lot of the parameters I tried to set for different things don't seem to work).

      Nothing seemed to work.

      My button class is a class which extends JToggleButton and I've tried to set margin, insets, etc in the constructor. I've even tried to override the methods getMargins and getInsets returning an Inset (0,0,0,0). Still nothing.

      For a test I tried filling the grid with colored JPanels (or JLabels I forget) and the spacing between grids was fine.

      It would make my UI much nicer/smaller if I could minimize the size that the toggle buttons take up by removing the spacing around the button as well as decreasing the spacing around the button Text.

      Any advice would be greatly appreciated. Thank you.

      PS.. while on the subject. Is there any way to change the color of the check in a checkbox without creating a custom Painter or affecting other controls?

      Edited by: user13414138 on Dec 15, 2011 2:34 PM

      Edited by: user13414138 on Dec 15, 2011 2:35 PM