Search code examples
javaswinglook-and-feelnimbus

Change JFrame's background in Sea-Glass Look and Feel


What's is the proper way to change to background of JFrame with Sea-Glass Look and Feel, so far I tried both :

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

and

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

But it didn't make any effect :

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

}


Solution

  • Seaglass Look and Feel is based on Nimbus, then you have to accepting its built-in themes or set Colors for Nimbus programatically