How to set component background color in JGraphX?

I want to create the background of a JGraphX ​​graph component ( https://github.com/jgraph/jgraphx ) of a specific color. I tried a standard call for any Swing component:

graphComponent.setBackground(Color.BLACK);

but it has no effect. I also tried to get the component to be repainted, no luck. Wrong call or is there any specific way to force update?

+4
source share
1 answer

Since mxGraphComponentextends JScrollPanewill change the background of the view port:

graphComponent.getViewport().setOpaque(true);
graphComponent.getViewport().setBackground(Color.BLACK);

From JScrollPane docs:

, , scrollPane.getViewport(). setBackground(). , scrollpane - , JViewport , , , , , , . , JScrollPane , , , .

+5

All Articles