Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Cant able to set Background color for panel..

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Marshal
Posts: 78433
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
karthikkumar, did it work?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22755
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't hijack month old threads.
 
Benjamin Kastelic
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k, so i'll make a new one
 
Did you miss me? Did you miss this tiny ad?
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic