aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes component colors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "component colors" Watch "component colors" New topic
Author

component colors

Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Hi all!
According to Java 2 Certification Study Guide (RHE):
If you do not explicitly set a component's foreground or background color, the component uses the foreground and background color of its immediate container.
I have an applet which contains several panels (navigate using a CardLayout). Each panel contains buttons. I thought that if the buttons were not explicitly assigned a background color, they should use the background color of the panel which contains them. This is not the case, however. I need to set the button background color explicitly to make it match the panel background. (If I do not, the button background defaults to gray). Does anyone know why this is the case?
Thanks in advance.
Stephanie
naren
Greenhorn

Joined: Aug 06, 2000
Posts: 9
hello,
i dont think the component will retain the color of immediate container.for any component,u need to explicitly set the color.
Also as panel is invisible component,and panel is a container for
placing components,the components will not inherit the color.
 
Don't get me started about those stupid light bulbs.
 
subject: component colors
 
Similar Threads
Choice comp. resists to change its back color...
Component/Container background color
Q#16 Marcus Green Layout Managers
foreground color
Checkbox label formatting