Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugoquinn2/fxpopup
FxPopup is a JavaFX library simplifies the creation of automatic forms and popup messages with minimal effort. With just a single line of code, developers can generate dynamic forms or display messages, while maintaining the flexibility to use custom views for both functionalities.
https://github.com/hugoquinn2/fxpopup
frontend javafx javafx-application javafx-components javafx-desktop-apps javafx-gui javafx-library library popup responsive responsive-design
Last synced: 6 days ago
JSON representation
FxPopup is a JavaFX library simplifies the creation of automatic forms and popup messages with minimal effort. With just a single line of code, developers can generate dynamic forms or display messages, while maintaining the flexibility to use custom views for both functionalities.
- Host: GitHub
- URL: https://github.com/hugoquinn2/fxpopup
- Owner: HugoQuinn2
- License: mit
- Created: 2024-12-06T02:52:33.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2025-02-04T22:30:06.000Z (9 days ago)
- Last Synced: 2025-02-04T23:26:39.316Z (9 days ago)
- Topics: frontend, javafx, javafx-application, javafx-components, javafx-desktop-apps, javafx-gui, javafx-library, library, popup, responsive, responsive-design
- Language: Java
- Homepage:
- Size: 377 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
FxPopupFxPopup is a JavaFX library that simplifies the creation of automatic forms
and popup messages with minimal effort. With just a single line of code, developers
can generate dynamic forms or display messages, while maintaining the flexibility to
use custom views for both functionalities.## Maven
```xmlio.github.hugoquinn2
fxpopup
1.1.0```
## Gradle
```groovy
repositories {
mavenCentral()
}dependencies {
implementation 'io.github.hugoquinn2:fxpopup:1.1.0'
}
```## Getting started
![Recording 2024-12-28 at 14 47 14](https://github.com/user-attachments/assets/366777a9-c1a2-4587-893e-4d90cd8d37d9)
FxPopup seamlessly injects XML code into a JavaFX application to display
notifications to the user. To function correctly, the main container of
the application must be a StackPane.
If your root parent is not a StackPane, FxPopup will automatically wrap
your root element in a StackPane to ensure compatibility.```java
//Example use lib
FxPopup fxPopup = new FxPopup();
fxPopup.add(/*Message object*/);
fxPopup.show(/*Model Form*/);
```
If you want to display automatic forms, FxPopup requires access to the form's model and validation class.
To achieve this, export the relevant modules to FxPopup at yourmodule-info.java
as shown in the following example:```java
module your.app {
requires fxpopup;
opens your.app.forms to fxpopup;
opens your.app.formsController to fxpopup;
}
```## Change Theme
FxPopup by default useSYSTEM
, but you can forceLIGHT
&DARK
theme in forms and popup with setTheme(Theme), example:```java
fxPopup.setTheme(Theme.DARK);
```## Message Popup.
To display a message it is necessary to create aMessage
object,
by default the messages will be displayed with positionPos.BOTTOM_RIGHT
.
Message required the paramstitle
,MessageType
andduration
for be displayed, by optional could addcontext
, if you want to show a message with more information.```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);
```### 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 getting the parent Message.```java
Message message = new Message("Just a message", MessageType.INFO, 3);
// Example mouse clicked on message action.
message.getParent().setOnMouseClicked(mouseEvent ->{
/*You code*/
});fxPopup.add(message);
```### Default message structure.
```ascii
VBox (#messageBody)
├── HBox
│ ├── Pane (#alertPane)
│ ├── VBox
│ │ ├── Label (#messageTitle)
│ │ └── Label (#messageContext)
│ └── Button (#buttonCloseMessage)```
## Message form.
FxPopup simplifies the process of creating forms automatically usingannotations
andmodels
.To generate automatic forms, you need to define a form model and a validation class. Additionally, if you want to display
error messages on the form, throw an exception with the desired message. This message will automatically appear on theLabel (#messageError)
:### Form model.
```java
@MessageForm(name = "User Log", validator = UserLogController.class)
public class UserLog {
@MessageField(label = "User Name", placeholder = "Write user name...", required = true)
private String userName;
@MessageField(label = "Password", placeholder = "Write password...", required = true, type = FieldType.PASSWORD)
private String password;
@MessageField(placeholder = "Remember me", type = FieldType.CHECK)
private boolean remember;
}
```### Form controller.
```java
public class UserLogController implements FxPopupForm {
@Override
public boolean validate(UserLog userLog) throws Exception {
if (!userLog.getUserName().equals("UserName"))
throw new Exception("User not valid.");if (!userLog.getPassword().equals("password"))
throw new Exception("Password not valid to user " + userLog.getUserName());return true;
}@Override
public void isValidForm(UserLog userLog) throws Exception {
if (!saveUser(userLog))
throw new Exception("User cant be saved.");if (userLog.isRemember())
if (!rememberUser(userLog))
throw new Exception("User cant be Remember.");
}
}
```
![]()
### Default form structure.
```ascii
VBox (#messageFormBody)
├── HBox
│ ├── Label (#titleForm)
│ ├── Button (#buttonClose)
├── VBox (#fieldsContainer)
├── Label (#messageError)
└── HBox
└── Button (#successButton)```