如何删除 TitledBorder 中标题周围的空格?我的意思是这个红色边框
一段代码:
Font f = new Font(Font.DIALOG, Font.PLAIN, 14);
Map m = f.getAttributes();
m.put(TextAttribute.BACKGROUND, Color.yellow);
Font ff = new Font(m);
Border mb = BorderFactory.createMatteBorder(20, 0, 0, 0, Color.yellow);
Border test = BorderFactory.createEmptyBorder(-2,-2,-2,-2);
Border mb6 = BorderFactory.createTitledBorder(mb, "Title", TitledBorder.CENTER, TitledBorder.TOP, ff, Color.DARK_GRAY);
mb6 = BorderFactory.createCompoundBorder(test, mb6);
Border mb2 = BorderFactory.createMatteBorder(1, 0, 0, 0, Color.gray);
mb2 = BorderFactory.createCompoundBorder(test,mb2);
Border mb3 = BorderFactory.createCompoundBorder(mb6, mb2);
Border mb4 = BorderFactory.createMatteBorder(1, 1, 1, 1, Color.gray);
Border mb5 = BorderFactory.createCompoundBorder(mb4, mb3);
modeSetPanel.setBackground(Color.red);
modeSetPanel.setBorder(mb5);