7

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

half transparent error message above ui

fabian
  • 80,457
  • 12
  • 86
  • 114
javier742
  • 73
  • 1
  • 2
  • 5
  • Possible duplicate of [JavaFX 2 custom popup pane](http://stackoverflow.com/questions/12717969/javafx-2-custom-popup-pane) – Neil Locketz Aug 25 '16 at 15:37

2 Answers2

7

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();
James_D
  • 201,275
  • 16
  • 291
  • 322
4

~~>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

Community
  • 1
  • 1
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93