title: Unable to make text areas uneditable in java
body: <p>I am pretty new to java, and I'm currently  learning how to make GUIs. To test out making them, I tried making one on my own. In order to find out how to make text boxes uneditable, I googled it and found it on the oracle website and tried it out. Unfortunately when I attempt to execute this, I am given the errors 'Syntax error on token(s), misplaced construct(s)' and 'Syntax error on token "false", delete this token'. This is what I had so far for the text area:</p>
  
  <pre><code>    JTextArea textArea = new JTextArea("Testing the text", 5, 10);
      JScrollPane scrollPane = new JScrollPane(textArea);
      textArea.setEditable(false);
  </code></pre>
  
  <p>The error is at the period between 'textArea' and 'setEditable' and (of course) the 'false'. I get the same kind of error when I try to do setText.</p>
  
  <p>If it helps, what I imported was:</p>
  
  <pre><code>    import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JOptionPane;
      import javax.swing.JPanel;
      import javax.swing.JTextField;
      import javax.swing.JTextArea;
      import javax.swing.JScrollPane;
  
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
  </code></pre>
  
  <p>I also extended JFrame and implemented ActionListener</p>
  
  <p>Any help would be appreciated :)</p>
  
  <p>So upon request, I am posting the rest of the code here. Unfortunately I haven't gotten very far in the program yet, but I will post what I have so far and try to finish it soon.</p>
  
  <p>RunTestGui.java file:</p>
  
  <pre><code>import javax.swing.JFrame;
  
  public class RunTestGui {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          TestGui gui = new TestGui();
          gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      }
  
  }
  </code></pre>
  
  <p>TestGui.java file:</p>
  
  <pre><code>/*import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;*/
  
  //import javax.swing.*;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  import javax.swing.JTextArea;
  import javax.swing.JScrollPane;
  
  //import java.awt.event.ActionEvent;
  //import java.awt.event.ActionListener;
  
  public class TestGui extends JFrame /*implements ActionListener*/ {
  //Global components
  JTextArea textArea = new JTextArea("Testing the text", 5, 10);
  JScrollPane scrollPane = new JScrollPane(textArea);
  textArea.setEditable(false);
  
  JTextField textBox;
  
  //constructor
  TestGui(String title){
  
  super(title);
  
  this.init();
  this.pack();
  this.setVisible(true);
  }//end constructor
  
  public void init(){
  
      JLabel ltextBox = new JLabel("TextBox: ");
  
      textBox = new JTextField(10);
  
      JPanel leftPanel = new JPanel();
      leftPanel.add(ltextBox);
      leftPanel.add(textBox);
  
      JPanel rightPanel = new JPanel();
      rightPanel.add(textArea);
  
  }
  
  
  
  }
  </code></pre>