This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cant able to set Background color for panel..  RSS feed

 
karthik tvn
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,

I have three panel.. consider panel1 ,panel 2 and panel3
The panel1's & panel2's Layout is Border Layout.
The panel2 is added into panel1's Border Layout center..
The panel3 is added into panel2's Border Layout center...

Now i was not able to set the background color for panel3....
But if i add the panel3 into panel2's Border Layout east, (or west or south or north) then i can able to set background color..


only if i am put into border layout center then only i was not able to set background color...

whats reason? please anybody give solution...i will be thankful...
 
Campbell Ritchie
Sheriff
Posts: 55315
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know . . . but something makes me think you are adding the 3 panels on top of each other. If that is the case, then you have changed the colours, you just can't see them!
 
G Estes
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this what you are trying? If so, this worked just fine for me...



The reason yours may not be working is that the CENTER object will occupy all un-used space. The EAST and WEST are not the same. Give your panel 3 a preferred size and you will see it...
[ July 30, 2008: Message edited by: Gil Estes ]
 
karthik tvn
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply...
i try this and i will pass comments...

Here you add panel p3 into Border Layout East...
p2.add(p3, BorderLayout.EAST);
but i need, add p3 into Border Layout CENTER...
 
G Estes
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that too and it worked. The issue you were having (I suspect) is no preferred size for the colorized panel.

Cheers!
 
karthik tvn
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply...
i try this and i will pass comments...

Here you add panel p3 into Border Layout East...
p2.add(p3, BorderLayout.EAST);
but i need, add p3 into Border Layout CENTER...
 
G Estes
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karthikkumar, did it work?
 
Benjamin Kastelic
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everbody!
I too have a similar problem like karthik...



that my Frame class for tetrism and i can't seem to set the background color for any of the JPanels, the color is shown only ont the borders.
Please help if you can.

Benjamin
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't hijack month old threads.
 
Benjamin Kastelic
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
k, so i'll make a new one
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!