こんにちは、Java でスイング プログレス バーの色を変更しようとしています。最初に、次のコードを使用してみました。
UIManager.put("ProgressBar.selectionBackground", Color.black);
UIManager.put("ProgressBar.selectionForeground", Color.white);
UIManager.put("ProgressBar.background", Color.white);
UIManager.put("ProgressBar.foreground", Color.RED);
m_progressBar.setBackground(Color.BLACK);
m_progressBar.setForeground(Color.red);
しかし、どのコマンドも効果がないようです!!! 私が設定しない限りm_progressBar.stringPainted(true)
、フォアグラウンドは変更されません。
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
とにかく、UI が初期化される前に呼び出される次のコマンドから問題が発生することはわかっています。
だから私の質問は: 1) 好奇心から:呼び出しがフォアグラウンド UI 設定をオーバーライドする
のはなぜですか? 2)コードの先頭を保持し、UI 設定を上書きするには
どうすればよいですか?stringPainted(true)
UIManager.setLookAndFeel
ありがとうございました!!