Issue with background color in JavaFX 8 -


looks there issue setting background colors panels in javafx 8.

i had been trying below, none of them set appropriate background colors.

vbox panel = new vbox(); panel.setalignment(pos.top_left);  // none of below work panel.setstyle("-fx-background-color: #ffffff;"); panel.setbackground(new background(new backgroundfill(color.white, cornerradii.empty, insets.empty))); 

is there wrong in way setting background color? used work earlier versions of javafx 2.2.

thanks.

both these work me. maybe post complete example?

import javafx.application.application; import javafx.beans.binding.bindings; import javafx.geometry.insets; import javafx.geometry.pos; import javafx.scene.scene; import javafx.scene.control.togglebutton; import javafx.scene.layout.background; import javafx.scene.layout.backgroundfill; import javafx.scene.layout.borderpane; import javafx.scene.layout.cornerradii; import javafx.scene.layout.hbox; import javafx.scene.layout.vbox; import javafx.scene.paint.color; import javafx.stage.stage;  public class panebackgroundtest extends application {      @override     public void start(stage primarystage) {         borderpane root = new borderpane();         vbox vbox = new vbox();         root.setcenter(vbox);          togglebutton toggle = new togglebutton("toggle color");         hbox controls = new hbox(5, toggle);         controls.setalignment(pos.center);         root.setbottom(controls);  //        vbox.styleproperty().bind(bindings.when(toggle.selectedproperty()) //                .then("-fx-background-color: cornflowerblue;") //                .otherwise("-fx-background-color: white;"));          vbox.backgroundproperty().bind(bindings.when(toggle.selectedproperty())                 .then(new background(new backgroundfill(color.cornflowerblue, cornerradii.empty, insets.empty)))                 .otherwise(new background(new backgroundfill(color.white, cornerradii.empty, insets.empty))));          scene scene = new scene(root, 300, 250);          primarystage.settitle("hello world!");         primarystage.setscene(scene);         primarystage.show();     }      public static void main(string[] args) {         launch(args);     }  } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -