Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugoquinn2/fxpopup
FxPopup It is a javafx library for displaying notifications in a very simple way.
https://github.com/hugoquinn2/fxpopup
javafx library
Last synced: about 1 month ago
JSON representation
FxPopup It is a javafx library for displaying notifications in a very simple way.
- Host: GitHub
- URL: https://github.com/hugoquinn2/fxpopup
- Owner: HugoQuinn2
- License: mit
- Created: 2024-12-06T02:52:33.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-12-13T08:05:35.000Z (about 1 month ago)
- Last Synced: 2024-12-13T09:19:12.433Z (about 1 month ago)
- Topics: javafx, library
- Language: Java
- Homepage:
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
FxPopupFxPopup It is a javafx library for displaying notifications in a very simple way.
## Maven
```xmlio.github.hugoquinn2
fxpopup
0.1.0```
## Getting started
FxPopup injects xml code into the JavaFx application to display notifications to the user, for this, the main container must be a StackPane, which is provided to the controller.
```java
// Basic load content
StackPane root = new StackPane();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/path/to/body.fxml"));
root.getChildren().add(fxmlLoader.load());
Scene scene = new Scene(root, 500, 500);//Example use lib
FxPopup fxPopup = new FxPopup(root);
```
## Show MessageTo display a message it is necessary to create a
Message
object, by default the messages will be displayed with the light themeTheme.LIGHT
```java
// Full Message.
Message exampleMessage = new Message(
"Title",
"Context",
MessageType.SUCCESS, // Message.INFO, Message.WARNING, Message.ERROR
10 // Duration seconds
);// Message without context.
Message simpleMessage = new Message(
"Title",
MessageType.SUCCESS, // Message.INFO, Message.WARNING, Message.ERROR
10 // Duration seconds
);fxPopup.add(exampleMessage);
fxPopup.add(simpleMessage);
```
### Change ThemeYou can change the theme with the function
fxPopup.setTheme(Theme.DARK)
, this will apply to all messages```java
fxPopup.setTheme(Theme.DARK);
```## Add action event to message
The functionalities of a message are not limited to simple plain text, it requires important actions. These actions can be added directly to the Message with the function:
message.setAction(EventType, EventHandler)
.```java
// Example mouse clicked on message action.
message.setAction(MouseEvent.MOUSE_CLICKED, event -> {
// Custom Action
...
});
```## Add custom theme.
If you don't like the themes already provided, it is possible to apply personal themes with the function,
message.setCss(Resource)
.```java
// Example style custom.
String css = Objects.requireNonNull(getClass().getResource("/resource/path/style.css")).toExternalForm();
message.setCss(css);
```### Default message structure.
```ascii
VBox (#messageBody)
├── HBox
│ ├── Pane (#alertPane)
│ ├── VBox
│ │ ├── Label (#messageTitle)
│ │ └── Label (#messageContext)
│ └── Button (#buttonCloseMessage)```