在这个程序中,我遇到了一个问题,因为按钮的颜色与我设置的不一样。
...
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");
...
(这些是唯一以某种方式设置按钮的行)
按钮图像:
我想要的按钮是:
无边框按钮:
最佳答案
试试这个
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/