gpt4 book ai didi

java - 删除 TitledBorder 周围的间距

转载 作者:行者123 更新时间:2023-12-01 07:13:50 25 4
gpt4 key购买 nike

javax.swing.border.TitledBorder 在边框边缘引入了 2 个像素的间距。这非常烦人,因为它破坏了与周围组件的对齐。

如何消除这个间距?

我正在寻找适合任何外观和感觉的解决方案。

最佳答案

不幸的是,这个边缘宽度在 TitledBorder 类中被硬编码。因此您无法删除此间距。

public class TitledBorder extends AbstractBorder
{
//...

// Space between the border and the component's edge
static protected final int EDGE_SPACING = 2;
}

但是您可以尝试扩展此类(覆盖方法“void PaintBorder(Component, Graphics, int, int, int, int)”或可能是“Insets getBorderInsets(Component, Insets)”)或实现您自己的边框从头开始。

关于java - 删除 TitledBorder 周围的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7906216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com