如何刪除TitledBorder中標題的空格?我的意思是紅色邊框
red border http://s019.radikal.ru/i634/1205/8a/1b40d810a4fe.jpg刪除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);
該紅色邊框可能已添加到您的JLabel中。但你需要發佈繪製這個窗口的代碼才能幫助我們 –
我添加了一段代碼 – Natalia
那麼,我期待看到的是在你的JLabel上調用setBorder,它接受一個邊框對象。有沒有在你的代碼中的某個地方打電話給setBorder? –