JMenu Transparent Bar JAVA

1

I have a panel and inside a JMenuBar and I want to make this transparent, but it comes out with a gray background and I can not change it. I put it opaque but it does not work nor does it change the background.

I tried this code but it does not work:

UIManager.put("jMGeneral.opaque", false);
jMGeneral.setBackground(Color.red);

I would like something like this:

    
asked by Isidro Martínez 03.08.2017 в 19:08
source

1 answer

2

Where you have:

jMGeneral.setBackground(Color.red);

Change it for this:

jMGeneral.setBackground(new Color(0f,0f,0f,0f));

The Color class is used to encapsulate colors in the default RGB color space or colors in arbitrary color spaces identified by ColorSpace .

Each color has an implicit alpha value of 1.0 or an explicit one provided in the constructor. The alpha value defines the transparency of a color and can be represented by a floating value in the range of 0,0 - 1,0 or 0 - 255 .

An alpha value of 1,0 or 255 means that the color is completely opaque and an alpha value of 0 or 0,0 means that the color is completely transparent. When you build a color with an explicit alpha or you get the color / alpha components of a color, the color components are never premultiplied by the alpha component.

Take a look at the documentation that is very understandable.

    
answered by 03.08.2017 в 19:20