In order to identify what parts of our UI needs to be styled, we need to use CSS Selectors. When using CSS in JavaFX, we can use two types of selectors. An ID selector and a class selector. The ID selector can be assigned to any node in our code. We use the setID method to assign a selector to the node. In the CSS file, we identify an ID using the # or hash sign.
- [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 program.…I left the initial template code there…
- What is JavaFX?
- Creating a simple JavaFX program
- Drawing lines, shapes, and text
- Applying effects
- Adding and animating images and charts
- Customizing interfaces with CSS
Skill Level Intermediate
1. Get Started with JavaFX
2. Sample Applications
4. User Interface Components
6. Custom UIs
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.