CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 1999
    Posts
    4

    How to change default background color?



    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

    [email protected]



  2. #2
    Join Date
    Aug 1999
    Posts
    7

    Re: How to change default background color?

    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>

  3. #3
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: How to change default background color?

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured