与layout无关。应该是你的代码的问题。自己再看一下,或者把代码帖出来。

解决方案 »

  1.   

    把你的bannerPanel的颜色改一下。
    bannerPanel.setBackground(tmpColor);
    试试看。
      

  2.   

    是啊,你应该修改的是panel的背景色
      

  3.   

    to fastmask and eshen2002:
    该了bannerPanel:改变的背景太大了。我只要BannerPanel中间的banner一块改变就可以了。to namowen: code is bellowing:
      this.getContentPane().setLayout(verticalFlowLayout1);    tcc = new JColorChooser(tmpColor);
        //Set up preview pane
        final JLabel banner = new JLabel("*** This is selected Color ***",
                                 JLabel.CENTER);
        banner.setBackground(tmpColor);
        banner.setForeground(Color.black);
        banner.setPreferredSize(new Dimension(100, 65));    bannerPanel = new JPanel(new BorderLayout());
        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButton1_actionPerformed(e);
          }
        });
        jButton2.setText("CANCEL");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButton2_actionPerformed(e);
          }
        });
        panel2.setLayout(xYLayout1);
        bannerPanel.add(banner, BorderLayout.CENTER);
        bannerPanel.setBorder(BorderFactory.createTitledBorder("Text Color"));    tcc.setPreviewPanel(new JPanel());
        tcc.getSelectionModel().addChangeListener(new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            tmpColor = tcc.getColor();
            banner.setBackground(tmpColor);      }
        });
        tcc.setBorder(BorderFactory.createTitledBorder(
                                             "Choose Text Color"));
        //Add the components to the frame
        Container contentPane = getContentPane();
        contentPane.add(bannerPanel, BorderLayout.SOUTH);
        contentPane.add(tcc, BorderLayout.CENTER);    panel1.setLayout(borderLayout1);
        getContentPane().add(panel1, null);
        this.getContentPane().add(panel2, null);
        panel2.add(jButton1, new XYConstraints(36, 3, 87, 24));
        panel2.add(jButton2, new XYConstraints(279, 4, 88, 23));    this.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
                    tmpColor = tcc.getColor();
           }
        });
      

  4.   

    你把label的背景色设成你想要的,然后修改label的不透明属性设为true,就行里。
      

  5.   

    thanks for the advice, fastmask :)   ^-^