那个setBackGround(SWTResourceManager.getColor(SWT.COLOR_RED));没用
啊只是button周围的颜色变了,按钮本身的颜色怎么改变?
setForeground(Color color):设置前景色。
setBackgrount(Color color):设置背景色。
是不是按钮没有设置非透明,setOpaque(true)
button.setForeground(Color color):设置前景色(即设置文字的颜色)。
button.setBackgrount(Color color):设置背景色。
mac系统加一句setBorderPainted(false);
JFrame frame = new JFrame("frame");
JButton button = new JButton("button");
button.setBounds(100, 10, 70, 30);
button.setBackground(Color.BLUE);
button.setForeground(Color.RED);
frame.add(button);
frame.setLayout(null);
frame.setLocationRelativeTo(null);
frame.setSize(300, 100);
frame.setVisible(true);
