【发布时间】:2020-03-30 20:56:56
【问题描述】:
我想同时更改按钮的背景颜色和前景色。我使用了 setBackground 和 setForeground 和 setOpaque(true),它适用于前景,但不适用于按钮的背景。按钮周围有点像黑色边框,但我希望按钮本身是黑色的。我该如何解决?
this.closeButton = new JButton ("Close");
this.closeButton.setBackground(Color.BLACK);
this.closeButton.setForeground(Color.PINK);
this.closeButton.setOpaque(true);
【问题讨论】:
-
编辑您的标签以指定哪个用户界面工具包:JavaFX、Swing、SWT、Vaadin 等。