This stackoverflow answer explains how to put a background image inside a TextField. However, I would like to know how to put arbitrary text as background, and do it without CSS, if possible. My first idea was to take a snapshot of Text node and use it as a background image, as follows (I am doing this inside a constructor of a class extending TextField):
Text text = new Text("TEST");
text.setFill(Color.RED);
WritableImage image = text.snapshot(new SnapshotParameters(), null);
this.setBackground(new Background(
new BackgroundImage(
image,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
new BackgroundPosition(Side.LEFT, 3D, false, Side.TOP, 50, true),
new BackgroundSize(image.getWidth(), image.getHeight(), false, false, false, false))));
However, it doesn't work. Background gets completely grayed out, and even the border disappears. Any idea how to do this? CSS solution is also acceptable.