問題描述
在 mac 上運行 jGRASP 時不顯示彩色按鈕? (Colored buttons don't show up when jGRASP is run on mac?)
我不確定我是否可以就 StackOverflow 上的代碼提出不明確的問題,但我目前有一個涉及彩色按鈕的 java 程序。在學校,當我在不是 Mac 的計算機上運行它時,jGRASP 顯示顏色並且運行得非常好,但是在我的個人 Macbook 上,無論我將顏色設置為什麼,單擊時按鈕都是白色並變為灰色. 所以我知道這不可能是我的代碼,除非有專門針對 Mac 的特殊方法,這是值得懷疑的。這是所有 Mac 的問題嗎?我正在使用
array[x].setForeground(Color.blue);
方法來設置所有內容。任何幫助將不勝感激!
參考解法
方法 1:
This may depend on the Look&Feel and Java version. In general, a component doesn't have to pay any attention to its foreground color.
(by mk8139、Larry Barowski)