88import java .util .Collections ;
99import java .util .List ;
1010import java .util .Locale ;
11+ import java .util .Objects ;
1112import java .util .Optional ;
1213import java .util .function .BiConsumer ;
1314import java .util .function .BiFunction ;
2223import javafx .application .ConditionalFeature ;
2324import javafx .application .Platform ;
2425import javafx .beans .NamedArg ;
25- import javafx .beans .binding .Bindings ;
2626import javafx .beans .property .BooleanProperty ;
2727import javafx .beans .property .DoubleProperty ;
2828import javafx .beans .property .ObjectProperty ;
3131import javafx .beans .property .SimpleObjectProperty ;
3232import javafx .beans .value .ObservableValue ;
3333import javafx .collections .FXCollections ;
34- import javafx .collections .ListChangeListener .Change ;
3534import javafx .collections .ObservableSet ;
3635import javafx .css .CssMetaData ;
3736import javafx .css .PseudoClass ;
4443import javafx .geometry .Bounds ;
4544import javafx .geometry .Insets ;
4645import javafx .geometry .Point2D ;
46+ import javafx .geometry .Pos ;
4747import javafx .scene .Node ;
4848import javafx .scene .control .ContextMenu ;
4949import javafx .scene .control .IndexRange ;
5757import javafx .scene .layout .Region ;
5858import javafx .scene .paint .Color ;
5959import javafx .scene .paint .Paint ;
60- import javafx .scene .shape .LineTo ;
61- import javafx .scene .shape .PathElement ;
6260import javafx .scene .text .TextFlow ;
6361
6462import org .fxmisc .flowless .Cell ;
@@ -394,10 +392,12 @@ public Node getParagraphGraphic( int parNdx ) {
394392 * This Node is shown to the user, centered over the area, when the area has no text content.
395393 * <br>To customize the placeholder's layout override {@link #configurePlaceholder( Node )}
396394 */
397- public final void setPlaceholder (Node value ) { placeHolderProp .set (value ); }
395+ public final void setPlaceholder (Node value ) { setPlaceholder (value ,Pos .CENTER ); }
396+ public void setPlaceholder (Node value , Pos where ) { placeHolderProp .set (value ); placeHolderPos = Objects .requireNonNull (where ); }
398397 private ObjectProperty <Node > placeHolderProp = new SimpleObjectProperty <>(this , "placeHolder" , null );
399398 public final ObjectProperty <Node > placeholderProperty () { return placeHolderProp ; }
400399 public final Node getPlaceholder () { return placeHolderProp .get (); }
400+ private Pos placeHolderPos = Pos .CENTER ;
401401
402402 private ObjectProperty <ContextMenu > contextMenu = new SimpleObjectProperty <>(null );
403403 @ Override public final ObjectProperty <ContextMenu > contextMenuObjectProperty () { return contextMenu ; }
@@ -904,6 +904,7 @@ protected void handleInputMethodEvent( InputMethodEvent event )
904904 }
905905
906906 private Node placeholder ;
907+ private boolean positionPlaceholder = false ;
907908
908909 private void displayPlaceHolder ( boolean show , Node newNode )
909910 {
@@ -929,15 +930,7 @@ private void displayPlaceHolder( boolean show, Node newNode )
929930 */
930931 protected void configurePlaceholder ( Node placeholder )
931932 {
932- placeholder .layoutYProperty ().bind ( Bindings .createDoubleBinding ( () ->
933- (getHeight () - placeholder .getLayoutBounds ().getHeight ()) / 2 ,
934- heightProperty (), placeholder .layoutBoundsProperty () )
935- );
936-
937- placeholder .layoutXProperty ().bind ( Bindings .createDoubleBinding ( () ->
938- (getWidth () - placeholder .getLayoutBounds ().getWidth ()) / 2 ,
939- widthProperty (), placeholder .layoutBoundsProperty () )
940- );
933+ positionPlaceholder = true ;
941934 }
942935
943936 /* ********************************************************************** *
@@ -1699,8 +1692,13 @@ protected void layoutChildren() {
16991692 });
17001693
17011694 Node holder = placeholder ;
1702- if (holder != null && holder .isResizable () && holder .isManaged ()) {
1703- holder .autosize ();
1695+ if (holder != null && holder .isManaged ()) {
1696+ if (holder .isResizable ()) holder .autosize ();
1697+ if (positionPlaceholder ) Region .positionInArea
1698+ (
1699+ holder , getLayoutX (), getLayoutY (), getWidth (), getHeight (), getBaselineOffset (),
1700+ ins , placeHolderPos .getHpos (), placeHolderPos .getVpos (), isSnapToPixel ()
1701+ );
17041702 }
17051703 }
17061704
0 commit comments