title: JTextArea position, setBounds does not work?
body: <p>I want a <code>JTextArea</code> in a certain position. I tried several things like using different <code>LayoutManager</code>s, no <code>LayoutManager</code> at all, <code>setLayout(null)</code> etc. Whatever I do, it seems like <code>setBounds()</code>, <code>setLocation()</code> and <code>setSize()</code> aren't working here, but I read about it and it said it should work. So what am I doing wrong?</p>
  
  <p>The <code>JTextArea</code> is always too high and the position doesn't change if I change the Parameters in <code>setBounds()</code>.</p>
  
  <pre><code>public class textarea extends JPanel {
  
      public static void main(String[] args){
          JFrame frame = new JFrame("text area");
          textarea content = new textarea();
          frame.setContentPane(content);
          frame.setLocation(120,70);
          frame.pack();
          frame.setVisible(true);
          frame.setSize(700,500);     
      }
  
      JPanel PanelForText;
  
      public textarea(){
          setBackground(Color.LIGHT_GRAY);
          setLayout(new FlowLayout(FlowLayout.CENTER,50,50));
  
          txtArea txt = new txtArea();
  
          PanelForText = new JPanel();
          PanelForText.setPreferredSize(new Dimension(500,300));
          PanelForText.setBorder(BorderFactory.createEtchedBorder());
          PanelForText.add(txt);
  
          add(PanelForText);
      }
  }
  
  
  public class txtArea extends JPanel {
  
      boolean textAreaCreated = false;
  
      public txtArea(){
          setBackground(Color.WHITE);
          setPreferredSize(new Dimension(496, 290));
      }
  
      public void paintComponent(Graphics g){
          super.paintComponent(g);
          g.setColor(Color.GRAY);
          g.fillRect(50, 25, 400, 245);
          if (!textAreaCreated)
              createTextArea();
      }
  
      public void createTextArea() {  
          JTextArea Text = new JTextArea();
          Text.setBounds(500,300,300,300);
          Text.setOpaque(false);
          Text.setWrapStyleWord(true);
          Text.setLineWrap(true); 
          Text.setBorder(BorderFactory.createLineBorder(Color.RED));
          add(Text);
          textAreaCreated = true;
      }
  }
  </code></pre>
  
  <p>Here is what I want it to look like:
  <img src="https://i.stack.imgur.com/tBIre.png" alt="enter image description here"></p>
  
  <p>And here is what it currently looks like:
  <img src="https://i.stack.imgur.com/lpfwP.png" alt="enter image description here"></p>
  
  <p>I did a few tutorials where they used <code>JTextField</code>s that were added to <code>JPanel</code>s, but I was wondering if I could just use a <code>JTextField</code> or <code>JTextArea</code> for more text WITHOUT adding it to a Panel first!</p>
  
  <p>Like I said, I was looking up "how to set <code>JTextArea</code> position" and it said to use <code>setBounds()</code>. Apparently that's not correct.. So again, all I want to know is how to do it better. Also: I did read a lot about the <code>LayoutManager</code>s, but for me trying to use it is more helpful than just reading about it... </p>
  
  <p>I tried that with rows and columns, but it didn't change the fact that the <code>JTextArea</code> was not in the right position. </p>
  
  <p>What I did was (in the CreateTextArea method):</p>
  
  <pre><code>public void createTextArea() {  
      JTextArea Text = new JTextArea(5,1);
      Text.setOpaque(false);
      Text.setWrapStyleWord(true);
      Text.setLineWrap(true); 
      Text.setBorder(BorderFactory.createLineBorder(Color.RED));
      add(Text);
      textAreaCreated = true;
  }
  </code></pre>