1

使用 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();
                }
            }
        });
    }    

}

4

1 回答 1

2

Seaglass Look and Feel基于Nimbus,那么您必须接受其内置主题或以编程方式为 Nimbus 设置颜色

于 2012-03-26T07:21:07.007 回答