1
我正在實現一個拼寫檢查器,並想知道是否有一種簡單/明顯的方式來強調某些不同顏色的文本,如紅色。用AttributeSet設置不同顏色的下劃線樣式常量
我把一切都建立並用下面的代碼,強調(也設置文本的顏色):
private AttributeSet getAttributeSet(Color foregroundColor) {
SimpleAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setForeground(attrs, foregroundColor);
StyleConstants.setUnderline(attrs, true);
}
上述代碼設置的字爲藍色,但也強調爲藍色。我需要能夠改變下劃線和厚度。有任何想法嗎?
感謝,
感謝您的答覆。在自定義高亮顯示畫筆中,顯示了以下內容:paintLayer(Graphics g,int offs0,int offs1,Shape bounds, JTextComponent c,View view) – maloney 2012-03-01 09:29:38
+1多數民衆贊成有用...只是用它作爲下劃線通過簡單更改y方程。 – 2012-08-22 12:11:17