There is such a code:

public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Dipsach_v0.2"); // Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ панСль ΠΏΠΎΡ‚ΠΎΡ‡Π½ΠΎΠΉ ΠΊΠΎΠΌΠΏΠΎΠ½ΠΎΠ²ΠΊΠΈ FlowPane Π² качСствС ΠΊΠΎΡ€Π½Π΅Π²ΠΎΠ³ΠΎ ΡƒΠ·Π»Π°. // Π£ΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ ΠΏΡ€ΠΎΠΌΠ΅ΠΆΡƒΡ‚ΠΊΠΈ ΠΌΡƒΠΆΠ΄Ρƒ элСмСнтами управлСния ΠΏΠΎ Π³ΠΎΡ€ΠΈΠ·ΠΎΠ½Ρ‚Π°Π»ΠΈ ΠΈ Π²Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΠΈ Ρ€Π°Π²Π½Ρ‹ΠΌΠΈ 10 FlowPane rootNode = new FlowPane(10, 10); /* GUI-ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ - это Ρ‚Π΅Π°Ρ‚Ρ€Π°Π»ΡŒΠ½ΠΎΠΉ искусство */ // Π‘ΠΎΠ·Π΄Π°Ρ‚ΡŒ сцСну Scene scene = new Scene(rootNode, 700, 500); // Π£ΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ сцСну Π½Π° подмостках primaryStage.setScene(scene); rootNode.getChildren().addAll(new DipsachTopMenuBar().getTopMenuBar()); scene.setFill(Color.BLACK); primaryStage.show(); } 

At the end I indicate:

 scene.setFill(Color.BLACK); 

But the color of the form does not change. What am I doing wrong ?

  • And if Scene scene = new Scene(rootNode, 700, 500, Color.BLACK); will help? .... And what is written in getTopMenuBar() and the DipsachTopMenuBar constructor? for, in principle, what is written should work .. apparently where something overlaps - Alexey Shimansky
  • Did - did not help. - faoxis
  • I wrote why. Check out other places. For example, comment rootNode.getChildren().addAll(new DipsachTopMenuBar().getTopMenuBar()); .... will the background be visible? Surely something is written there - Aleksey Shimansky
  • Yes, without adding the DipsachTopMenuBar class, everything works well, but even if I add new MenuBar (), everything breaks down. What's wrong ? - faoxis
  • It is necessary to look at how you add and what is written in the code, layouts, sizes. add more code what have you where - Aleksey Shimansky

1 answer 1

The color of the scene will be changed if you remove all the content from it. It is now closed by rootNode. To fix this, write this line!

 rootNode.setStyle("-fx-backround-color: #000000");