5

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?

3 Answers 3

7

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");

enter image description here

Source

Sign up to request clarification or add additional context in comments.

4 Comments

the lib behind that is unavailable.
The link in the blog post is broken, but you can still access the author's source on github: link
Did you use a library or you Notification class from javax.management package ?
Again please, I don't understand the question.
1

You can use the ControlsFx library to create notifications http://docs.controlsfx.org/org/controlsfx/control/NotificationPane.html

1 Comment

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
0

you can try JFXToast see github that can help you doing this work

this is an class for empelement toast in javafx

2 Comments

links are highly discourage you should provide some details about link.
Link is dead. This one may be comparable: github.com/vincenzopalazzo/JFXToast

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.