public void handle(ActionEvent event) {
Button btn2 = new Button("Show content 2");
btn2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
AnchorPane content2 = new AnchorPane();
content2.setStyle("-fx-background-color: green");
content2.setPrefSize(300, 300);
SVGPath icon = new SVGPath();
icon.setContent("M0,0 L10,0 L10,10 L0,10 Z");
icon.setStyle("-fx-fill: green;");
bar.addItem("Item 2", icon, content2);
bp.setCenter(content2);
}
});
AnchorPane content1 = new AnchorPane();
content1.setStyle("-fx-background-color: blue");
content1.setPrefSize(300, 300);
content1.getChildren().add(btn2);
SVGPath icon = new SVGPath();
icon.setContent("M0,0 L10,0 L10,10 L0,10 Z");
icon.setStyle("-fx-fill: blue;");
bar.addItem("Item 1", icon, content1);
bp.setCenter(content1);
}
});
AnchorPane homeContent = new AnchorPane();
homeContent.setStyle("-fx-background-color: red");
homeContent.setPrefSize(300, 300);
homeContent.getChildren().add(btn);
bar.addHome(homeContent);
bp.setTop(bar);
bp.setCenter(homeContent);