javier742
javier742

Reputation: 83

How can I do an error messages in JavaFX

I want to make error message like this on JavaFX. How can I do it?

half transparent error message above ui

Upvotes: 8

Views: 16856

Answers (2)

GOXR3PLUS
GOXR3PLUS

Reputation: 7255

~~>Default Way

Alert class and some more are already in JavaFX library a full tutorial here

How to costumize an Alert?Here

^^Using ControlsFX library^^

There is a ready JavaFX library that make messages like in your icon.I am talking about ControlsFX library

~~>More Costumizable

It contains a Class named NotificationPane which you can modify in the way you want to display messages like JavaFX Alert and more complicated.

~~>For your situation

I would use Notifications class which display messages in the bootom,top,right,left and combination of them in the screen.

Example Code:

Notifications.create() .title("Title Text") .text("Hello World 0!") .showWarning();

Image:

Look here Edit this cause for some reason isn't displayed in stackoverflow

~~>How to costumize Notifications:

Customize ControlsFX Notifications

Upvotes: 4

James_D
James_D

Reputation: 209553

Use an Alert:

Alert errorAlert = new Alert(AlertType.ERROR);
errorAlert.setHeaderText("Input not valid");
errorAlert.setContentText("The size of First Name must be between 2 and 25 characters");
errorAlert.showAndWait();

Upvotes: 8

Related Questions