Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在选择 JButton 时更改默认颜色。默认情况下,它是“浅蓝色”。当按下 JButton 时,背景会在 0.2 秒内变为浅蓝色。
我不想setBackground()。我想更改默认属性。有没有类似的东西:
setBackground()
JButton button = new JButton(text); button.setSelectionColor(Color);
这是由 LAF 控制的。
您也许可以使用:
UIManager.put("Button.select", new Color( 0, 255, 0) );
在您创建按钮之前,在您的程序开始时。
但是,这将适用于您的应用程序中的所有按钮。