From the course: Learning JavaFX GUI Development
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Use selectors
From the course: Learning JavaFX GUI Development
Use selectors
- [Voiceover] At this point you might be wondering, how does the CSS know which nodes to style? In order to identify which parts of our UI needs to be styled we need to use CSS Selectors. When using CSS and JavaFX, we can use two types of selectors. The first one in an ID selector. The ID selector is assigned using the setId method. In the CSS file, we identify this type of selector using the pound sign, or sometimes called the hash mark. The second type of selector is a class selector. The class selector is assigned to nodes that have the same class, but we can also create a new class selector with a string name to be added as a tag to any existing JavaFX node. When using class type selectors, we will invoke the getStyle class method dot add and then in parenthesis the name of our style class. The method allows us to have multiple style classes for styling a node. The class selector is prefixed with a dot in the CSS file. Let' s take a look at some examples. Here's a sample netbeans…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.