Vote count:
0
I have one BorderPane which has content in the top and center region. The top area is a status area which should use little real estate. I want the center region to always have 32 pixels of an indent to make the node(GridPane) appear disconnected - this part seems to work OK. When I have another BorderPane nested in the center region, I want to use the top and center regions of the nested pane and still have the indent like the GridPane. The issue is, the offset for indenting the nested top region does not seem to have any reference point and I can can't get it indented as it seems to vanish as the indent increases.
.contentnode {
-fx-background-color: rgba(0, 0, 0, 0.6);
-fx-background-radius: 5;
-fx-background-insets: 32;
-fx-border-radius: 45 45 45 45;
-fx-hgap: 64;
-fx-padding: 64;
}
.dialognode {
-fx-background-color: lightslategray;
-fx-padding: 15 20 20 15;
-fx-hgap: 64;
-fx-background-insets: 0 32 32 32;
-fx-border-radius: 45 45 45 45;
-fx-border-width: 1;
}
.dialogtitle {
-fx-text-alignment: center;
-fx-text-fill: #EEEEEE;
-fx-background-color: burlywood;
-fx-border-radius: 15 15 0 0;
-fx-background-radius: 15 15 0 0;
-fx-background-insets: 0 32 0 32;
}
public class House extends Application {
public House house = this;
Label labelClock = new Label();
Label labelDialogTitle = new Label();
Button btnTemperature = new Button();
Button btnStatus = new Button();
Button btnPower = new Button();
BorderPane rootBorder = new BorderPane();
BorderPane dialogBorder = new BorderPane();
HBox statusBar = addStatusBar();
HBox dialogTitleBar = addDialogTitle();
GridPane homeGrid = addHomeGrid();
GridPane temperatureGrid = addTemperatureGrid();
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) {
primaryStage.setTitle("ROOT");
rootBorder.setTop(statusBar);
rootBorder.setCenter(homeGrid);
dialogBorder.setTop(dialogTitleBar);
setupActions();
rootBorder.getStylesheets().add(House.class.getResource("MainWindow.css").toExternalForm());
btnTemperature.setText("T");
btnPower.setText("P");
btnStatus.setText("S");
Scene homeScene = new Scene(rootBorder, 300, 250);
Scene dialogScene = new Scene(dialogBorder, 300, 250);
primaryStage.setScene(homeScene);
primaryStage.show();
}
public void setupActions() {
btnTemperature.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
rootBorder.setCenter(dialogBorder);
dialogBorder.setCenter(temperatureGrid);
}
});
}
public HBox addStatusBar() {
HBox hbox = new HBox();
hbox.setPadding(new Insets(15, 12, 15, 12));
hbox.setSpacing(10);
hbox.setStyle("-fx-background-color: #336699;");
labelClock.setText("CLOCK");
hbox.getChildren().add(labelClock);
return hbox;
}
public HBox addDialogTitle() {
HBox hbox = new HBox();
hbox.setStyle("");
hbox.getStyleClass().add("dialogtitle");
labelDialogTitle.getStyleClass().add("dialogtitle");
labelDialogTitle.setText("DIALOGTITLE");
hbox.getChildren().add(labelDialogTitle);
return hbox;
}
public GridPane addHomeGrid() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 10, 0, 10));
grid.add(btnTemperature, 0, 0);
grid.add(btnPower, 0, 1);
grid.add(btnStatus, 0, 2);
grid.getStyleClass().add("contentnode");
return grid;
}
public GridPane addTemperatureGrid() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 10, 0, 10));
grid.getStyleClass().add("dialognode");
return grid;
}
public GridPane addSystemStatusGrid() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 10, 0, 10));
grid.getStyleClass().add("dialognode");
return grid;
}
}
asked 3 mins ago
JavaFX CSS With Nested BorderPane
Aucun commentaire:
Enregistrer un commentaire