title: Set size of jpanel on a JFrame explicitly
body: <p>I have <code>JPanel</code> with a border, the problem is that when I add the panel on the <code>JFrame</code> it takes the panel size although I set the preferred size for the panel  using <code>setPreferredSize</code>.   The layout of the frame is 'BoxLayout' and here's the code:</p>
  
  <pre><code>public class ActionForm extends JFrame {
  
  
      JPanel namePanel;
      JPanel descPanel;
      JLabel actionName;
      JLabel nameLabel;
      JTextField nameTextField, descTextField;
      FlowLayout toolBarLayout = new FlowLayout();     
  
      public ActionForm() {
          this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
          TitledBorder nameBorder= BorderFactory.createTitledBorder(
              "Change Description");
          nameBorder.setTitleJustification(TitledBorder.LEFT);
          namePanel = new JPanel(toolBarLayout);
          namePanel.setPreferredSize(new Dimension(150, 150));
          nameLabel = new JLabel("ButtonName");
          nameTextField = new JTextField("Action's Name", 50);
          namePanel.add(nameLabel);
          namePanel.add(nameTextField);
          namePanel.setBorder(nameBorder);
          namePanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
          this.add(namePanel);
      }
  
      public static void main(String[] args) {
          ActionForm form = new ActionForm();
          form.setVisible(true);
          form.setSize(970, 500);
          form.setResizable(false);
      }
  }
  </code></pre>
  
  <p>Why the size of the panel doesn't change?</p>