How can I set custom background color for JMenuBar
and JMenu
objects inside it? I tried .setBackgroundColor
and it does not work!
It's very simple.
Here's the code:
menu.setBackground(Color.DARK_GRAY);
Similarly you can add your own color like GREEN, BLUE, DARK_GRAY, LIGHT_GRAY, BLACK, RED, etc..
This is the only simple way to change any color of any component in java.
Note: This is applicable for all components in Java Swing only. it is useless in JavaFX, JFace, SWT but not AWT and Swing
Thank you,
Dereck Smith