Skip to main content

Custom Controls and Components, Canvas API and GraphicsContext

Learn Custom Controls and Components, Canvas API and GraphicsContext (Phase 13 · Advanced JavaFX (Advanced), JavaFX) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Custom controls and components • Levels of customisation : (1) compose existing nodes into a reusable Region / VBox subclass or an FXML fx:root component (most common); (2) style a control with CSS and cell factories; (3) a full custom control = Control subclass + Skin ( SkinBase ) + CSS (behaviour/skin separation; for libraries); (4) draw yourself on a Canvas or Region with shapes. Expose properties ( StyleableProperty for CSS), events and a sensible default size ( computePrefWidth ).

More lessons in Phase 13 · Advanced JavaFX (Advanced)