

You can also navigate to the CSS file via the CSS Analyzer panel, as explained later in Using the CSS Analyzer Panel.įigure 10-4 CSS Analyzer Panel Displayed (Click image to enlarge.)ĭescription of "Figure 10-4 CSS Analyzer Panel Displayed (Click image to enlarge.)" You can also reveal the CSS file's location in your system using the Reveal command that is also available in the drop-down menu. Select the Open command for the CSS file you want to edit. In the Stylesheets list view of the Properties section of the Inspector panel, click on the CSS file you want to edit.Ĭlick the drop-down arrow on the bottom right of the list view, as shown in Figure 10-2. You can edit an existing CSS file with your system editor by using the following steps: In this case, once the style sheet is attached to the Scene, the styles defined in the “root” class are applied to the layout in the Content panel. This Preview command is useful when the “root” style class is defined in the style sheet. In Scene Builder, you can simulate the attachment of a style sheet to an application Scene by selecting Preview, then Scene Style Sheets, and finally choosing Add a Style Sheet or Open a Style Sheet option. The CSS files referenced from the Stylesheets properties are referenced from within the FXML file and so they are deployed with the FXML file. You can define the specific style class to use with a UI element by adding it to the Style Class list view in the Properties section of the Inspector panel. The darkList style class is defined in the IssueTracking.css style sheet and inherited by the ListView element from its container parent, the topmost AnchorPane container.įigure 10-1 Properties Section with Style Class and Style Sheet List Views Displayedĭescription of "Figure 10-1 Properties Section with Style Class and Style Sheet List Views Displayed"ĬSS rules that are defined on a parent element can be used to style the parent UI element itself and all of its children elements.

The right side of the figure shows the darkList style class assigned to the ListView element. The left side of Figure 10-1 shows the Properties section of the Inspector panel with the IssueTracking.css file assigned to the topmost Anchor Pane used in the layout. You can attach a style sheet to any part of your FXML layout, from the topmost parent UI element to the lowest. By using the Stylesheets list view in the JavaFX CSS subsection of the Properties section of the Inspector panel, you can assign a CSS file to use on a selected UI element in your FXML layout if that UI element is either a container or a UI control. You can add the CSS rules at the Scene level, within a given container, or by an inline styling at the Node level. The changes you save in the CSS file that is used by the current FXML layout displayed in the Content panel is immediately rendered by Scene Builder.

Scene Builder currently does not generate CSS files, but enables you to use your local CSS editor to create and modify your CSS file.

You can customize the style used in your application by changing the component's properties via the Properties section of the Inspector panel or by defining your own styling rules in a CSS file. Scene Builder immediately renders this predefined JavaFX style when you drag the UI control from the Library panel to the Content or Hierarchy panel. The JavaFX UI controls used by Scene Builder are pre-styled with a default JavaFX look and feel. This chapter describes the Cascading Style Sheet (CSS) support and describes the CSS Analyzer feature that JavaFX Scene Builder provides. 10 Skinning with CSS and the CSS Analyzer
