This README provides a comprehensive guide on how to use and extend the JavaFX application template.
-
Copy an FXML File:
- Navigate to the
FXML/Appfolder. - Copy one of the FXML files (except
app.fxmlandmenu.fxml) and edit it. - Reminder: Change the controller associated with the new FXML file.
- Navigate to the
-
Update Menu.fxml:
- Open
FXML/App/Menu.fxml. - Copy an existing button, then rename its
fx:idand text to suit your needs.
- Open
-
Add a New ENUM:
- Go to
MENU_OPTIONinView/Appand add a new ENUM.
- Go to
-
Modify ApplicationViewFactory:
- Create a new
AnchorPane. - Add a method to extract the
AnchorPanefrom the new FXML file (follow the existing methods as a guide).
- Create a new
-
Update Menu_Controller:
- Extract the new
fx:idinController/App/Menu_Controller.
- Extract the new
-
Set Button Actions:
- Add an
onActionevent to the new button to trigger opening the view when clicked. - Example:
ViewCentral.getInstance().getApplicationViewFactory() .setSelectedMenuOption(MENU_OPTION.[YOUR_NEW_ENUM]);
- Add an
-
Set Button Icon (Optional):
- Customize the button icon if required.
-
Create a New Controller:
- Add a new controller in
Controller/App.
- Add a new controller in
-
Link FXML to Controller:
- Connect your new FXML file to the created controller.
-
Extract FXML IDs:
- Extract all
fx:idvalues from the FXML file and define corresponding variables in the controller.
- Extract all
-
Implement Required Interfaces:
- Implement
Initializableand, if applicable,CRUDControllerInterface.
- Implement
-
Define Methods:
- Add methods such as
decor(),setupData(),insertData(), andsetButtonActions().
- Add methods such as
-
Initialize Controller:
- Call the defined methods inside the
initialize()method.
- Call the defined methods inside the
NOTIFICATION_TYPE.WARNING: Yellow color with an alert icon.NOTIFICATION_TYPE.SUCCESS: Green color with a check icon.NOTIFICATION_TYPE.INFOR: Blue color with an "info" icon.
-
Push Notification (Auto-Disappear):
- Disappears automatically after 5 seconds.
- Example:
ViewCentral.getInstance().getStartViewFactory() .pushNotification(NOTIFICATION_TYPE.WARNING, anchorPane, "Example Message");
-
Stand-On Notification (Persistent):
- Remains visible until manually closed.
- Example:
ViewCentral.getInstance().getStartViewFactory() .standOnNotification(NOTIFICATION_TYPE.WARNING, anchorPane, "Example Message");
-
Confirmation Message:
- Returns
TRUEif "OK" is clicked; otherwise,FALSE. - Example:
if (!ViewCentral.getInstance().getStartViewFactory().confirmMessage("Are you sure?")) { return; }
- Returns
UIDecorator.setSuccessButton: Green button.UIDecorator.setNormalButton: Blue button.UIDecorator.setDangerButton: Red button.
UIDecorator.setSuccessButton(create_btn, UIDecorator.ADD(), null);
UIDecorator.setNormalButton(update_btn, UIDecorator.EDIT(), null);
UIDecorator.setDangerButton(delete_btn, UIDecorator.DELETE(), null);- First Parameter: The button to which the icon will be added.
- Second Parameter: The icon to attach (use predefined icons from the
UIDecoratorclass). - Third Parameter: The text for the button. Set it to
nullto remove the text.
When adding a new model in the /Model directory, follow these steps:
-
Implement
Serializable:- Ensure the new model implements the
Serializableinterface for data persistence.
- Ensure the new model implements the
-
Use
SimpleProperty:- Use
SimplePropertyfor real-time updates in JavaFX.
- Use
-
Generate IDs Automatically:
- Use the
Database.IDGeneratormethod to auto-generate IDs in the constructor.int id = Database.IDGenerator(Item.class);
- Use the
-
Define Getter, Setter, and Property Methods:
- Example implementations:
- Getter:
public String getName() { return name; }
- Setter:
public void setName(String name) { this.name = name; if (nameProperty == null) nameProperty = new SimpleStringProperty(); nameProperty.set(name); }
- Property:
public StringProperty nameProperty() { if (nameProperty == null) nameProperty = new SimpleStringProperty(name); return nameProperty; }
- Getter:
- Example implementations:
-
Update
Database.class:- Add a New List: Add a new
List<...>as a variable inDatabase.class. - Initialize the List: Initialize the list in the constructor.
- Save Data: Include the list in the
saveData()method. - Load Data: Load the list in the
loadData()method. - Getter: Write a getter for the new list.
- DAO Implementation: Implement the corresponding DAO for the model.
- Add a New List: Add a new
-
Add a New ID System (if required):
- Define a new
Map<Integer, Boolean>variable to manage IDs. - Update the
IDGeneratorclass to save, load, and manage the new ID system.
- Define a new
The project includes several helper classes for common functionality:
UIDecorator: Manages UI decorations and styles.ImageUtils: Provides utility methods to handle images.TaskUtils: Manages multithreading tasks efficiently.DateUtils: Handles date formatting and date-related operations.InputValidator: Includes common input validation methods.