Independent Tasks
Using FXML and the learned Layout Containers, complete the following tasks.
Task 1: Login Screen
Create a new FXML file (e.g., login-view.fxml). The design should look like this:
- In the center of the window, place a
GridPane(Grid Container). - The
GridPaneshould contain:- A
Labelfor “Username:” and aTextFieldfor input. - A
Labelfor “Password:” and aPasswordFieldfor input. - Two
Buttonelements: “Login” and “Cancel”.
- A
- The buttons should be arranged horizontally (this can be done in an
HBox(Horizontal Box) inside theGridPaneor by usingGridPane.columnSpan). - Use
paddingandspacingfor a better appearance. - Center the
GridPanein the window (you can use aStackPane(Stacking Container) as the root of the scene or configure theGridPanealignmentsettings).
Task 2: Toolbar Application with Multiple Sections
Create a new FXML file (e.g., multi-section-view.fxml). The design should include:
BorderPane(Border Container) as the main Layout Container.- Top Region (
top): AnHBox(Horizontal Box) containing severalButtonelements that mimic a Toolbar – for example, “New”, “Open”, “Save”. - Left Region (
left): AVBox(Vertical Box) containing aListView(or severalButtonelements) representing navigation items. - Central Region (
center): AStackPane(Stacking Container) containing at least three different graphical elements (these could be simpleLabelnodes inside aVBoxor more complex Layout Containers likeGridPane,FlowPane, orAnchorPanefrom the previous example), with each havingvisible="false"by default. The goal is to demonstrate that aStackPanecan hold different views. - Bottom Region (
bottom): AnHBox(Horizontal Box) for a status bar. - Right Region (
right): AFlowPane(Flow Container) with severalLabelorTextFieldcontrols showing “Properties” or “Details”.
Task 3: Product Gallery
Create an FXML file for a simple product gallery.
- Use a
TilePane(another Layout Container not covered in detail, but it works similarly toFlowPanewhile arranging elements in uniform tiles) or aFlowPane(Flow Container). - Each “tile” should contain a
VBox(Vertical Box) with anImageView(for the product) and twoLabelnodes (for name and price). - Use placeholder images (you can use any
*.pngor*.jpgfiles from the internet). - The goal is to demonstrate an adaptive arrangement of many similar elements.
Task 4: Settings Form
Create a new FXML file settings-view.fxml. The goal is to practice selection controls.
-
Root:
VBoxwith centering andspacingof15px. -
Elements:
-
Labelwith the title “Notification Settings”. -
CheckBoxfor “Email Notifications”. -
CheckBoxfor “SMS Notifications” (selected by default). -
Below them, add a
Separator(horizontal line). -
Label“Interface Theme:”. - Three
RadioButtonelements: “Light”, “Dark”, “System”.- Important: The three buttons must be in a single
ToggleGroupso that only one can be selected at a time.
- Important: The three buttons must be in a single
- One
ToggleButtoncontrol with the text “Mode: Online/Offline”.
-
Task 5: Feedback Form
Create a new FXML file feedback-view.fxml. This task focuses on working with long text and positioning.
-
Root:
AnchorPane. -
Elements:
-
At the top:
Label“Your feedback is important to us”. - In the middle:
TextAreafor free text input.-
Use
promptText="Write your comment here...". -
Set
wrapText="true"so that the text wraps automatically. -
Anchor it (
AnchorPaneanchors) at50pxfrom all sides so it expands with the window.
-
- At the bottom: An
HBoxcontaining a “Send”Buttonand a “Clear”Button, positioned in the bottom-right corner using anchoring.
-
Task 6: Application Launcher
Create an FXML file launcher-config-view.fxml that combines everything learned.
-
Root:
BorderPane. - Center (
center):GridPanewith the following fields:-
Row 0:
Label“Application Name:” and aTextField. -
Row 1:
Label“Description:” and aTextArea(with a height for 3 rows). -
Row 2:
Label“Launch Mode:” and anHBoxcontaining twoRadioButtonnodes (“Windowed”, “Full Screen”). -
Row 3:
Label“Options:” and aVBoxwith twoCheckBoxnodes (“Auto-update”, “Start with system”).
-
- Bottom (
bottom): AnHBoxwith a “Save Changes” button, set asdefaultButton="true"(to glow blue and respond to the Enter key).