它不起作用,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);
}
}