title: Java swing JPanel save data from Textarea to string variable
body: <p>I have a GUI which has a textarea and a "save button" on it.
  I want the text that is written in the textarea to be saved when the button is pressed. I have written this code so far:</p>
  
  <pre><code>   //Creates textbox
     JTextArea text = new JTextArea();
     text.setBounds(48, 44, 160, 16); //int (x,y,width,height)
  </code></pre>
  
  <p>and</p>
  
  <pre><code> //Button
   JButton saveButton = new JButton("Save");
   saveButton.setBounds(10, 185, 120, 20); //int (x,y,width,height)
  </code></pre>
  
  <p>And I have also added it to the JPanel. Everything appears as it should, I just don't know how to save the text that is written in the textarea, I have tried googling it, but it seems like there is many ways to do so and I don't know how I can implement it in a simple way that I understand. Thanks.</p>
  
  <p>EDIT:
  I want to save the data into a string, so I can save it into a database.</p>