改变海玻外观中的JFrame背景

时间:2012-03-26 01:43:08

标签: java swing look-and-feel nimbus

使用Sea-Glass Look and Feel更改为JFrame背景的正确方法是什么,到目前为止,我尝试了两种方法:

frame.getContentPane().setBackground(Color.blue);

JPanel x = new JPanel();
x.setBackground(Color.red);
frame.setContentPane(x);

但它没有产生任何影响:

import javax.swing.*;
import com.seaglasslookandfeel.*;
import java.awt.*;
import java.awt.Color.*; 
public class BORDER_TEST {
public static void main(String[] a){

        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {

                    UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
                    JFrame frame = new JFrame();
                    JPanel x = new JPanel();
                    x.setBackground(Color.red);
                    frame.setContentPane(x);

                    //frame.getContentPane().setBackground(Color.blue);
                    frame.setPreferredSize(new Dimension(900,350));
                    frame.setAlwaysOnTop(true);
                    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                    } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }    

}

1 个答案:

答案 0 :(得分:2)

Seaglass Look and Feel基于Nimbus,您必须接受其内置主题或设置Colors for Nimbus programatically