Class Decorator


  • public class Decorator
    extends Object
    The Decorator class is responsible for accessing decorations for a given node. Through this class you may therefore add and remove decorations as desired.

    Code Example

    Say you have a TextField that you want to decorate. You would simply do the following:

     
     TextField textfield = new TextField();
     Node decoration = ... // could be an ImageView or any Node!
     Decorator.addDecoration(textfield, new GraphicDecoration(decoration, Pos.CENTER_RIGHT));
     

    Similarly, if we wanted to add a CSS style class (e.g. because we have some css that knows to make the 'warning' style class turn the TextField a lovely shade of bright red, we would simply do the following:

     
     TextField textfield = new TextField();
     Decorator.addDecoration(textfield, new StyleClassDecoration("warning");
     
    See Also:
    Decoration
    • Method Detail

      • addDecoration

        public static final void addDecoration​(Node target,
                                               Decoration decoration)
        Adds the given decoration to the given node.
        Parameters:
        target - The node to add the decoration to.
        decoration - The decoration to add to the node.
      • removeDecoration

        public static final void removeDecoration​(Node target,
                                                  Decoration decoration)
        Removes the given decoration from the given node.
        Parameters:
        target - The node to remove the decoration from.
        decoration - The decoration to remove from the node.
      • removeAllDecorations

        public static final void removeAllDecorations​(Node target)
        Removes all the decorations that have previously been set on the given node.
        Parameters:
        target - The node from which all previously set decorations should be removed.
      • getDecorations

        public static final ObservableList<Decoration> getDecorations​(Node target)
        Returns all the currently set decorations for the given node.
        Parameters:
        target - The node for which all currently set decorations are required.
        Returns:
        An ObservableList of the currently set decorations for the given node.