简体   繁体   English

Synthetica JButton边距

[英]Synthetica JButton Margins

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 . 因此,我有一个针对雇主的日历解决方案,其中我使用的是自定义外观(Synthetica),表中的每个单元格都包含一个带有按钮列表和PAGE_AXIS BoxLayoutJPanel 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. 我试图缩小每个按钮之间的间距,以使它们彼此邻接,并且我尝试将边框设置为null,但这会破坏按钮的外观。 I have used the following (as recommended by Oracle to view the actual size of the components) code; 我已经使用了以下代码(由Oracle建议,以查看组件的实际大小);

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. 操纵按钮的绑定属性: setBorderPainted(false) 等。 , as suggested here . ,如这里所建议。

  • See if a suitable sizeVariant is available, as shown here . 看看是否合适sizeVariant是可用的,如图所示这里

  • Use a custom UI delegate based on BasicButtonUI , as shown here and here . 使用基于BasicButtonUI的自定义UI委托,如此此处所示。

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. 我尝试让Synthetica L&F进行查看,但似乎您必须创建一个我不想做的帐户。 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. 无论如何,快速浏览一下网站,我发现了一个页面,该页面指示您如何查看和配置L&F中设置的某些值。 Might be worth having a look there. 可能值得在那里看看。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM