0

ControlsFX has an awesome control called NotificationPane, which can easily be use like so

NotificationPane np = new NotificationPane();
np.setText("What to be displayed here");

What I am wondering, is it possible to extends it in such a way that, instead of it displaying text to display a Node.

fabian
  • 80,457
  • 12
  • 86
  • 114
Yunus Einsteinium
  • 1,102
  • 4
  • 21
  • 55

2 Answers2

1

You don't need to extends it. Just use the constructor that accepts a node.

http://controlsfx.bitbucket.org/org/controlsfx/control/NotificationPane.html#NotificationPane-javafx.scene.Node-

yamenk
  • 46,736
  • 10
  • 93
  • 87
  • 1
    This is wrong. See the [content property](http://controlsfx.bitbucket.org/org/controlsfx/control/NotificationPane.html#contentProperty--) official description. Quote *The content property represents what is shown in the scene that is not within the notification bar. In other words, it is what the notification bar should appear on top of.* – Jules Sam. Randolph Oct 18 '16 at 22:37
1

The Node that NotificationPane accepts in the constructor is actually the content pane OVER which the notification appears, not the content of the notification itself.

There is however a way to achieve what you asked. From the JavaDocs:

The graphic property represents the Node to show within the popup notification bar that appears on top of the content that is within the NotificationPane. Despite the term 'graphic', this can be an arbitrarily complex scenegraph in its own right.

This means that you can indeed put complex Nodes (even whole trees) inside the notification. As long as the Text/Action properties are null, it will occupy all available space (or up to the preferred/max sizes of the node itself), leaving space for the closing button.

GeckoOBac
  • 31
  • 7