如何在textarea中为JavaFX设置图像?

时间:2017-04-09 14:18:45

标签: javafx-8

它不起作用,textarea的背景仍为null

public class dsgf extends Application {

  @Override
  public void start(Stage primarystage) throws Exception {

    HBox b = new HBox();

    Image image = new Image("ph/background.jpg");
    BackgroundImage c = new BackgroundImage(image, null, null, null, null);
    Background g = new Background(c);

    TextArea t = new TextArea();

    t.setBackground(g);//

    b.getChildren().add(t);
    Scene scene = new Scene(b);

    primarystage.setScene(scene);
    primarystage.show();
  }

  public static void main(String[] args) {

    launch(args);
  }
}

1 个答案:

答案 0 :(得分:0)

也许这个帖子给你一个提示: Transparent background of a textarea in JavaFX 8