java - 在 JLabel 的开头和图标之间设置一个间隙
问题描述
我有一个像这样的 Java Swing 表单和 JLabel:
我需要做的是在 JLabel 的开头插入一个空白:
所以它不会粘在边界线上。
注1:我已经使用过jLabName.setIconTextGap(35);
,但它做了以下事情:
我需要在图标之前而不是之后插入间隙!
注2:边框设置和类型等设置:
解决方案
您可以为此使用复合边框。
例如。
//get border of your component which is button as you say
Border border = myButton.getBorder();
//create a new empty border with name it margin
Border margin = new EmptyBorder(0,10,0,0); //top 0, left 10 , bottom 0, right 0
//now set compound border to your button(component), with margin
myButton.setBorder(new CompoundBorder(border, margin));
//NOTE: CompoundBorder accepts two borders as arguments, first one is inner border and last one is outer border
推荐阅读
- scala - 我将如何合并这两个数据帧以在 Spark Scala 中生成第三个数据帧?
- ios - Swift:Firebase 查询永远不会调用
- windows - LsaLookupAuthenticationPackage 返回 0xc00000fe
- postgresql - 使用 ts_vectors 和 ST_Distance 搜索结果
- laravel - SQLSTATE[HY000]:一般错误:1366 错误的字符串值:'\x8C5\xB7\x9D\x11\xFD...' 用于 laravel voyager 坐标输入
- python - 等待 Scapy 回调函数
- r - R biomaRt 包:获取链接数据库中的所有值
- android - Fragment中BottomNavigation和Scrollview的问题
- wordpress - 具有分类属性的 WP_Query 不返回结果
- c++ - 在类的char数组中插入元素