JGoodies を使用している場合、JButton の色を変更するにはどうすればよいWindowsLookAndFeel
ですか? 色を変更した後でも、ボタンをクリックしたときに何らかの視覚的な表示があるはずです。色のグラデーションとクリック アニメーションは、JGoodies と同じである必要はありません。
setBackground()
andを使用するとsetForeground()
、ボタンのアウトラインとボタンのテキストの色のみが変更されます。
import com.jgoodies.looks.windows.WindowsLookAndFeel;
...
public class Test {
public static void main(String[] args) throws UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
JFrame frame = new JFrame();
frame.setSize(50, 100);
JButton button = new JButton("Button");
button.setBackground(Color.GREEN);
button.setForeground(Color.RED);
button.setOpaque(true);
frame.add(button);
frame.setVisible(true);
}
}
ボタンの輪郭だけでなく、ボタン全体の色を設定したいと思います。(これは、WindowsLookAndFeel
が使用されていない場合に発生します。)
また、色を変更しようとしましたcom.jgoodies.looks.windows.WindowsBorders#getButtonBorder()
が、これは効果がないようです。