Separator
In JavaFX, a Separator is a simple visual component used to divide content in a user interface. It can be horizontal or vertical, depending on its orientation. Unlike panes or layout managers, it’s purely decorative and doesn’t handle any input.
Example: Using a Separator
FXML (hello-view.fxml)
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.VBox?>
<VBox spacing="10" alignment="CENTER"
xmlns="http://javafx.com/javafx/17"
xmlns:fx="http://javafx.com/fxml/1">
<Button text="Button 1"/>
<Separator orientation="HORIZONTAL"/>
<Button text="Button 2"/>
</VBox>
Key Points:
Orientation:
- Horizontal (default): divides top and bottom.
- Vertical: divides left and right.
<Separator orientation="VERTICAL"/>Usage: Usually placed inside layouts (
VBox,HBox,GridPane) to visually separate groups of controls.No events: It’s purely visual and doesn’t respond to clicks or other user actions.