I started to work to user notification message similar to JGrowl for JavaFX.
public void newMessage()
{
final Stage newConnDialog = new Stage();
newConnDialog.initStyle(StageStyle.UNDECORATED);
newConnDialog.initModality(Modality.WINDOW_MODAL);
// Set pisition
newConnDialog.setX(1050); //secondStage.setX(primaryStage.getX() + 250);
newConnDialog.setY(150);
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(5);
grid.setVgap(5);
grid.setPadding(new Insets(20, 20, 20, 20));
// text
Text productName = new Text("Test");
productName.setFont(Font.font("Verdana", 12));
grid.add(productName, 0, 2);
// Configure dialog size and background color
Scene aboutDialogScene = new Scene(grid, 200, 100, Color.WHITESMOKE);
newConnDialog.setScene(aboutDialogScene);
newConnDialog.show();
}
I have a basic knowledge about JavaFX. Can you give me some basic advice what will be the best way to implement this component. For example do I need to create new Stage or I can use other component as stage. How I can hide the component after 10 seconds activity and etc. Any advice will be highly appreciated.
P.S. I found this example for JavaFX 1.3 Maybe it can be rewritten for JavaFX 2.2?
This is one possible solution by using the Enzo library:
// Create a custom Notification without icon
Notification info = new Notification("Title", "Info-Message");
// Show the custom notification
Notifier.INSTANCE.notify(info);
// Show a predefined Warning notification
Notifier.INSTANCE.notifyWarning("This is a warning");
Source
You can use the ControlsFx library to create notifications http://docs.controlsfx.org/org/controlsfx/control/NotificationPane.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With