2014-10-12 65 views

回答

0

下面的代碼不正是你想要

public class Main extends Application { 
    @Override 
    public void start(Stage primaryStage) { 
     try { 

     AnchorPane root = new AnchorPane(); 
     Scene scene = new Scene(root,400,400); 
     scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); 


     TextArea ta=new TextArea(); 
     ta.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() { 
      @Override 
      public void handle(KeyEvent event) { 
       // your algorithm to change height 
       ta.setPrefHeight(ta.getPrefHeight()+10); 
      } 
     }); 
     root.getChildren().add(ta); 

     primaryStage.setScene(scene); 
     primaryStage.show(); 

    } catch(Exception e) { 
     e.printStackTrace(); 
    } 
} 

public static void main(String[] args) { 
    launch(args); 
} 
+0

謝謝!!!!!!!!!!!! – user3860345 2014-10-13 20:35:33