Skip to content

Commit

Permalink
docs(framework): Add more documentation and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStegii committed Feb 26, 2024
1 parent 9422db3 commit 858357d
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ framework. This can be done by creating a field containing your instance (e.g. w
When the corresponding controller is rendered, the framework will automatically set the resource bundle as the resource
bundle of the FXML file.

To set a default resource bundle once, you can use the `setDefaultResourceBundle` method of the `FulibFxApp` class.
The resource bundle will be used if no resource bundle has been specified for the controller.

### 📏 Title

The title of a controller or component can be set by annotating The class with `@Title`.
Expand All @@ -193,13 +196,34 @@ public class TodoController {
}
```

When displaying this controller, the framework will automatically set the title of the window to "My Todo List".
If the controller or component specifies a resource bundle, the title can be a key in the resource bundle (e.g. `@Title("%title.key")`).
The framework will then automatically set the title of the controller/component to the value of the key in the resource bundle.
See the section about [internationalization](#-internationalization) for more information.

```java
@Controller
@Title("%title.todo")
public class TodoController {

@Resource
ResourceBundle resourceBundle;
}
```

When displaying this controller/component, the framework will automatically set the title of the window to "My Todo List".
In order to eliminate redundancy, you can use the `setTitlePattern` method of the `FulibFxApp` class to set a pattern
which will be used to format the title of the window. The pattern can either be provided as a string containing a placeholder
for the title or as a function taking the title as an argument and returning the formatted title.

If the controller or component specifies a resource bundle, the title can be a key in the resource bundle (e.g. `@Title("%title.key")`).
The framework will then automatically set the title of the window to the value of the key in the resource bundle.
```java

@Override
public void start(Stage primaryStage) {
super.start(primaryStage);
setTitlePattern("TODO - %s"); // Results in "TODO - My Todo List"
setTitlePattern(title -> "TODO - " + title + " v1.0"); // Results in "TODO - My Todo List v1.0"
}
```

## 💭 Components

Expand Down

0 comments on commit 858357d

Please sign in to comment.