JMenu as a submenu?
Hi all
I have a JMenu which is a submenu of another
What my problem is is I cannot change the background color of the submenu
here is the code
menuBar =new JMenuBar();
menuBar.setBackground(Color.blue);
menu =new JMenu("Menu");
menu.setBackground(Color.blue);
submenu =new JMenuItem("submenu");
submenu.setBackground(Color.blue);
item1 =new JMenuItem("item1");
item1.setBackground(Color.blue);
submenu.add(item1);
menu.add(submenu);
menuBar.add(menu);
Although I change their background color to blue, the submenu is still grey, which I can't construe.
what is wrong with this simple code?
thanks
[917 byte] By [
voywodaa] at [2007-10-3 2:12:09]

Here is the whole code
import javax.swing.*;
import java.awt.*;
public class Deneme extends JFrame {
JMenuBar menuBar;
JMenu menu, submenu;
JMenuItem item1, item2;
public Deneme() {
menuBar = new JMenuBar();
menuBar.setBackground(Color.blue);
menu = new JMenu("Menu");
menu.setBackground(Color.blue);
submenu = new JMenu("submenu");
submenu.setBackground(Color.blue);
item1 = new JMenuItem("item1");
item1.setBackground(Color.blue);
submenu.add(item1);
menu.add(submenu);
menuBar.add(menu);
setJMenuBar(menuBar);
setVisible(true);
setSize(200, 100);
}
public static void main(String[]args){
new Deneme();
}
}
thanks
Message was edited by:
voywoda
Your code works, to a degree. If you change the size of the window you will see a blue menubar. I suggest that you look at the following link and take a look at the main methods used in those examples, and implement your program accordingly.
http://java.sun.com/docs/books/tutorial/uiswing/index.html
> If you change the size of the window you will see a blue menubar.
It seems I will not :)
I think I couldn't explain my problem, ( it must be because of my bad english ). My problem is not with the menubar or the menu, my problem is with the submenu that I stated in the whole code above.
here is the image of my problem
http://img264.imageshack.us/my.php?image=submenuhk1.jpg
What I want is to change the color of the "submenu" part in the image to be blue, but setBackground doesn't work
thanks