2017-04-09 73 views
0

它不起作用,textarea的背景仍然是null如何在textarea中为JavaFX设置图像?

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); 
    } 
} 
+0

的[添加与CSS文本框右侧的小图片](可能的复制http://stackoverflow.com/questions/13159156 /添加一个小图片在右边的textfield-with-css) –

回答