怎么变换整个得背景颜色??

解决方案 »

  1.   

    换什么的背景?
    setBackgound(Color c)方法
    颜色没有变的话先setOpaque(true)
      

  2.   

    import java.awt.*;
    import java.awt.event.*;public class mywindow extends Frame implements ActionListener
    {
    Button b1=new Button("1");
    Button b2=new Button("2");
    Button b3=new Button("3");

    public mywindow(String title)
    {
    super(title);
    setLayout(new FlowLayout());
    add(b1);
    b1.addActionListener(this); } public void actionPerformed(ActionEvent e)
    {
    setBackground(Color.red);
    }

    } 楼主可以参考一下
    希望对你有帮助
      

  3.   

    为什么总说red,,,white这些变量不对???哎!>....................
      

  4.   

    大哥,应该是Color.red  Color.white 等等...
      

  5.   

    我用的是contentPane=(JPanel)this.getContentPane();
    changecolor.setLabel("变换颜色");
    changecolor.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    setBackground(Color.red);
    }但是只有乱点界面的时候有以瞬间的红色底色......一般还是白的界面...怎么回事阿..麻烦大家了!
      

  6.   

    void jButton1_actionPerformed(ActionEvent e) {
        Color backcolor=JColorChooser.showDialog(this,"选择颜色",contentPane.getBackground());
        if(backcolor!=null)
        {contentPane.setBackground(backcolor);}
      }