[英]How do I change the color of an actual JButton in Java? Not the background and not the text
這是不容易實現的。 問題在於,可插入的外觀會繪制按鈕內容,並且會以其認為合適的方式進行繪制。 例如,某些L&F可能會繪制不使用背景色的漸變。
我建議您使用自定義圖像( JButton.setIcon()
)而沒有內容區域( JButton.setContentAreaFilled(false)
)。
另外,您可以創建一個自定義組件來繪制元素本身,從而覆蓋JComponent.paintComponent()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.