Java Swing 按钮: setColor doesn't display the right color

标签 java swing user-interface button

在这个程序中,我遇到了一个问题,因为按钮的颜色与我设置的不一样。

...

jButton1 = new javax.swing.JButton();
jButton1.setBackground(new Color(103,175,63));
jButton1.setFont(new java.awt.Font("Futura", 1, 14));
jButton1.setForeground(Color.white);
jButton1.setText("Potvrdit");

...

(这些是唯一以某种方式设置按钮的行)

按钮图像:
button image

我想要的按钮是:
how I want the button to be

无边框按钮:
button without border

最佳答案

试试这个

 b1.setContentAreaFilled(false);
 b1.setBackground(new Color(103,175,63));
 b1.setFont(new java.awt.Font("Futura", 1, 14));
 b1.setForeground(Color.white);
 b1.setText("Potvrdit");
 b1.setOpaque(true);
 b1.setBorder(new LineBorder(new Color(103,175,63), 1, true));

关于Java Swing 按钮: setColor doesn't display the right color,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49763352/

相关文章:

java - 如何根据用户输入创建 JLabel 和 JRadioButton?

java - 如何在不使用swing的情况下连接netbeans中的两个JFrame?

java - 在 JTextArea 下面添加按钮

iphone - 在设置下打开热点取代屏幕 Xcode iPhone 的用户界面

java - 模块依赖Java解释

java - "x = x++"之后的 x 是什么?

java - Java 中的输出流

java - 在指定时间内执行部分代码

java - 同表级联删除

java - Android SAXParser,解析成数组并获取子节点