# JavaFX Fundamentals: Stages, Scenes & UI Building Blocks
> Master JavaFX architecture, UI controls, and layout panes. Learn how to build your first Java window with stages, scenes, and nodes in this guide.

Tags: javafx, java-programming, ui-design, software-development, layout-panes, coding-tutorial, desktop-apps
## JavaFX Architecture
* **Stage**: The top-level container representing the application window (the 'theater stage').
* **Scene**: Holds all visual content; only one scene is displayed on a stage at a time.
* **Nodes**: Individual UI elements such as buttons, labels, and text fields that make up the scene graph.

## Stage & Scene in Detail
* **Stage**: Top-level window container created by the JavaFX runtime. Can be primary or secondary.
* **Scene**: Requires a root node (like VBox or StackPane) and is attached to the stage via `stage.setScene()`.
* **Workflow**: 1. Stage is created -> 2. Scene is built -> 3. Scene added to Stage -> 4. Stage is shown.

## Nodes & UI Controls in JavaFX
* **Button**: `Button btn = new Button("Click Me");` triggers actions.
* **Label**: `Label lbl = new Label("Hello!");` for non-editable text.
* **TextField/PasswordField**: Inputs for plain or masked text.
* **TextArea**: For multi-line text input.
* **Selection Controls**: CheckBox (toggle) and RadioButton (single selection in a group).

## Layout Panes in JavaFX
* **VBox**: Stacks children vertically (e.g., forms, sidebars).
* **HBox**: Arranges children horizontally (e.g., toolbars).
* **BorderPane**: 5-region layout (Top, Bottom, Left, Right, Center) for main app structures.
* **GridPane**: Flexible rows and columns for precise positioning (e.g., calculators).
* **FlowPane**: Wraps children based on available space.

## Creating Your First JavaFX Application
* **Process**: Import packages -> Extend `Application` -> Override `start()` method -> Build Stage & Scene -> Add UI Controls -> Call `launch()` in `main()`.
* **Key Method**: The `start(Stage primaryStage)` method is the main entry point for the UI logic.
---
This presentation was created with [Bobr AI](https://bobr.ai) — an AI presentation generator.