Stretching in Java Swing Box
<p>I have a code:</p>

<pre><code>    Box box_general = Box.createHorizontalBox();
    Box box_panel1 = Box.createVerticalBox();
    Box box_panel2 = Box.createVerticalBox();

    JPanel jpanel_1 = new JPanel();

    jpanel_1.setPreferredSize(new Dimension(50, 152));
    jpanel_1.setOpaque(true);
    jpanel_1.setBorder(BorderFactory.createLineBorder(Color.BLUE));

    JPanel jpanel_2 = new JPanel();

    jpanel_2.setPreferredSize(new Dimension(340, 152));
    jpanel_2.setOpaque(true);
    jpanel_2.setBorder(BorderFactory.createLineBorder(Color.RED));

    JTextField jtxtf_populationSize = new JTextField();
    jtxtf_populationSize.setSize(10, 20);
    JTextField jtxtf_processorsAmount = new JTextField();

    JButton jbtn_loadProcesses = new JButton("File path");
    box_panel1.add(Box.createRigidArea(new Dimension(0,4)));        
    box_panel1.add(jtxtf_processorsAmount);
    box_panel1.add(Box.createRigidArea(new Dimension(0,20)));       
    box_panel1.add(jbtn_loadProcesses);
    jpanel_1.add(box_panel1);

    JLabel jlbl_populationSize = new JLabel("Enter the population size");
    JLabel jlbl_processorsAmount = new JLabel("Enter the amount of processors");
    JLabel jlbl_loadProcesses = new JLabel("Load processes from file");

    jlbl_populationSize.setFont(font);
    jlbl_processorsAmount.setFont(font);
    jlbl_loadProcesses.setFont(font);

    box_panel2.add(jlbl_populationSize);
    box_panel2.add(Box.createRigidArea(new Dimension(0,4)));        
    box_panel2.add(jlbl_processorsAmount);
    box_panel2.add(Box.createRigidArea(new Dimension(0,15)));       
    box_panel2.add(jlbl_loadProcesses);
    jpanel_2.add(box_panel2);

    box_general.add(jpanel_2);
    box_general.add(Box.createRigidArea(new Dimension(10,0)));
    box_general.add(jpanel_1);
</code></pre>

<p>It creates 3 boxes, where the general box contains two other boxes. The problem is: in the box all the compopents are stretched of width. For example, there is a line <code>jtxtf_populationSize.setSize(10, 20);</code> but this text field is stretched in the box_panel1 on width. I tried to use a <code>BoxLayout</code> with it's Alignment_X but this didn't work.</p>

<p>Could you, please, advise me, what to do - how to avoid stretching? </p>
