JButton jb1 = new JButton("确认"); jb1.setBackground(Color.red);确定是可以改变JButton 的背景色的
import java.awt.*; import javax.swing.*;public class test extends JFrame{ public static void main(String args[]){ test t = new test(); t.setSize(500,400); t.setLocationRelativeTo(null); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.setVisible(true); } public test(){ JButton jbt = new JButton("sdsds"); //jck.setForeground(Color.yellow); jbt.setBackground(Color.red); add(jbt); } } 这是我自己写的test,为什么button筐的颜色还是没改变呢?难道是我哪儿写错了?
jb1.setBackground(Color.red);确定是可以改变JButton 的背景色的
import javax.swing.*;public class test extends JFrame{
public static void main(String args[]){
test t = new test();
t.setSize(500,400);
t.setLocationRelativeTo(null);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
t.setVisible(true);
}
public test(){
JButton jbt = new JButton("sdsds");
//jck.setForeground(Color.yellow);
jbt.setBackground(Color.red);
add(jbt);
}
}
这是我自己写的test,为什么button筐的颜色还是没改变呢?难道是我哪儿写错了?