Click to See Complete Forum and Search --> : How to change default background color?


Neil Weber
February 1st, 1999, 12:24 PM
Has anybody had any luck with changing the default background color? Looking

through the O'Reilly Java Swing book, it appears that all I have to do is

UIManager.put("window", Color.green). I did that before and after switching to the system L&F, but didn't see any effect. I also tried to just set the default background color for buttons by UIManager.put("Button.background", Color.green) and also didn't see any effect. Any ideas?


Thanks,

Neil Weber

neilw@technicalities.com

vglass
August 12th, 1999, 09:10 PM
Try c.setBackground(Color) where c is an instance of a component and Color is an instance of Color



Van Glass
<a href="http://www.jscape.com">http://www.jscape.com</a>

unicman
August 13th, 1999, 12:20 AM
I also tried it both on JDK1.1.5 and JDK1.2. I didn't get green color for the frame, but I got color of button as green.


import java.awt.*;
//import com.sun.java.swing.*;
import javax.swing.*;

public class rnd
extends JPanel
{
public rnd()
{
super( new BorderLayout() );
setOpaque( true );
add( new JLabel("hi"), BorderLayout.CENTER );
add( new JButton("HI"), BorderLayout.NORTH );
}

public static void main( String args[] )
{
UIManager.put("Window",Color.green);
UIManager.put("Button.background",Color.green);
JFrame jf = new JFrame();
jf.setSize(100,100);
jf.setContentPane( new rnd() );
jf.show();
}
}





- UnicMan
http://members.tripod.com/unicman