title: How can I make a TextArea stretch to fill the content, expanding the parent in the process?
body: <p>So I have a TextArea and as the user pastes paragraphs into it, or just writes in it, I want it to expand vertically to reveal all the available text. I.e. not to use a scrollbar in the text field itself... much like what happens on many web pages. Many users, myself included, don't like to be forced to edit in a small window. Exactly how Facebook status updates box works.</p>
  
  <p>I've tried</p>
  
  <pre><code>myTextArea.autoSize()
  </code></pre>
  
  <p>wrapped in an</p>
  
  <p><code>myTextArea.textProperty().addListener(new ChangeListener()....);</code></p>
  
  <p>but that doesn't work. I think it's happy autosizing to its current size.</p>
  
  <p>The left, right &amp; top anchors are set to it's parent AnchorPane. I've tried it with the bottom attached and not attached. Ideally I'd like to grow the anchor pane as the textarea grows.</p>
  
  <p>I don't mind reading the TextProperty and calculating a trigger size which I set myself... but this seems a hacky approach IF there is already a best practise. The number of properties and sub objects of javafx is sufficiently daunting that it seems like a good point to ask the question here, rather than trying to figure out how many pixels the font/paragraphs etc are taking up.</p>
  
  <p>Update:</p>
  
  <p>So I thought maybe I was overthinking it, and all I needed to do was to switch the scrollbars off and the rest would happen. Alas, looking for available fields and methods for "scroll", "vertical", "vbar" comes up with nothing I can use. ScrollTopProperty looks like it's for something else.</p>