1

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

}

mKorbel
  • 109,525
  • 20
  • 134
  • 319
TU_HEO DAKAI
  • 2,197
  • 8
  • 28
  • 39
  • Load L&F via UIManager before any code in your main method instead. For example: http://stackoverflow.com/questions/9541045/how-to-set-jframe-look-and-feel After that, do whatever you want i.e. change its background – ee. Mar 26 '12 at 02:30
  • Some L&Fs may need you to change a few UI properties by calling setProperty() or something. You may need to look into its doc. There is also L&Fs with a "buggy" implementation that doesn't allow you to change to something that you want! If this happens, you may need to override its paintComponent() to consume its default UI component paint behavior and apply a new component paint behavior. – ee. Mar 26 '12 at 02:48

1 Answers1

2

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

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319