Coloring JPanels


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Coloring JPanels

  1. #1
    Join Date
    Sep 2002
    Posts
    16

    Angry Coloring JPanels

    hey everyone,

    I have the following code in the constructor of my JFrame class.
    Code:
    {
    	super();
    
    	
    	mainPanel.setForeground(Color.red);
    
    	contentPane.add(mainPanel);
    	this.setResizable(false);
    	this.setTitle("Find...");
    	this.addWindowListener(new WindowAdapter()
    	{
    		public void windowClosing(WindowEvent anEvent)
    		{
    			doDispose();
    		}
    	});
    	this.setSize(300, 200);
    	this.show();
    }
    The problem is i want to color the JPanel so I can see it when I add other panels (to help me w/doing layout stuff).

    Why wont the panel color turn red?????
    Jayceepoo

  2. #2
    Join Date
    Sep 2002
    Posts
    16
    Attention everyone, I have an announcement

    I am an IDIOT!!!!!

    I guess if i want to change the color of the actual JPanel, I should use the .setbBackground method, instead of the .setForeground method.

    Isnt it crappy how the stupidest little mistakes can drive you crazy for hours!
    Jayceepoo

  3. #3
    Join Date
    Oct 2002
    Posts
    2
    I'm glad you found your own mistake.

    If you are having difficulty building layouts, why not try a better layout system?

    I encourage you to try the Oculus Layout System at javalayout.com.

    It makes creating layouts with Swing fast and easy. Things stretch and align the way you'd expect, and there is no need to understand or use complicated constraints. It comes with a visual drag-and-drop GUI builder for immediate layout design feedback. It generates Java code which is simple and organized. This makes it readable and maintainable.

    It has saved me tons of time building GUIs!

    Bill
    Make intelligent Java layouts easily with Oculus Layout!
    http://www.javalayout.com
    javalayout-info@oculustech.com

  4. #4
    Join Date
    Sep 2002
    Posts
    16
    You must be a sales man for that layout designer... The only 2 posts that you've done are pushing for people to try that. Better yet, its like you copied one post, and pasted it to another thread...

    I don't think these boards are for advertisement purposes.
    Jayceepoo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center