title: Java - JPanel with margins and JTextArea inside
body: <p>I want to create something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/RzZAa.png" alt="Centered text area"></p>
  
  <p>Main panel has its margins (x), and TextArea in the center of that panel which almost fills up the panel.
  At the bottom is another panel with custom size (height y), which can be toggled visible and unvisible with some shortcut. Bottom Panel has FlowLayout and few elements.</p>
  
  <p>The problem is I have no idea how to do this.</p>
  
  <p>BoxLayout has no margins.</p>
  
  <p>I tried with GridBagLayout but I doesn't work or I can't understand it enough :(</p>
  
  <p>I tried also with setting JTextArea margins</p>
  
  <pre><code>textMain.setMargin(new Insets(insetTop, insetLeft, insetBottom, insetRight));
  </code></pre>
  
  <p>but when there is a lot of text, top and bottom margin disappear. So now I'm trying with Panels.</p>
  
  <p>Can someone help me with this please?</p>