I edited the code and added the following two lines.
menu.setBackground(Color.RED);// This is the first line that I added submenu.setBackground(Color.GREEN);// This is the seccond line that I added
It worked as expected when I tested with java version "1.4.2_04" But, unfortunately, it is not working with java version "1.5.0" The background color is set properly when I use java version other than "1.5.0" But when I use java version "1.5.0", The back ground is still the default background color.
Am I doing anything wrong..? Or is this a bug..? I tested in windows 98 and XP. Both produced the same result. So I guess the problem is with jre. Here is the code
Thanks Shahabas E Shabeer
The greatest pleasure in life is doing what peoples say you can not do.
Indeed, at this point it's a good rule of thumb to explicitly set components opaque (or not opaque) because what they instantiate to is not always predictable. As the above poster hinted at, this can be a problem with JPanel's as well, especially when used for a content pane.
Joined: Feb 23, 2004
Yes .. you are right.. I think the transparancy of the component depends on the look and feel used. The code that I posted worked fine when I set native look and feel than the default swing look and feel. I do now believe that it is always better to explicitly set the transparancy of the component. Thanks a lot for all your help cheers Shahabas E Shabeer