title: java boxlayout space after adding jpanel
body: <p>I have container jpanel in which i used a boxlayout manager and what i do is i add another panels inside in which the added panel contains a label and textfield using flowlayout manager. everytime i add a panel inside it creates an annoying big space after another added panel. I want to reduce the spacing of the panels i have tried using setsize and setpreferredsize method to adjust it. Here is my code: </p>
  
  <pre><code>  JPanel global = new JPanel();
    global.setLayout(new BoxLayout(global, BoxLayout.Y_AXIS));
    global.setPreferredSize(new Dimension(500,312));
    global.setSize(500,312);
    global.setBounds(8, 5, 500, 312);
    global.setBorder(BorderFactory.createLineBorder(Color.black));
    global.setBackground(Color.white);
    //Elements of global
  
    JLabel label1 = new JLabel("Global Settings");
    label1.setAlignmentX(Component.CENTER_ALIGNMENT);
    label1.setFont(new Font("tahoma", Font.BOLD, 17));
    global.add(label1);
    global.add(new JSeparator());
  
  
    //Name Field
    JPanel c = new JPanel();
    c.setSize(100, 1);
    c.setPreferredSize(new Dimension(100,1));
    c.setLayout(new FlowLayout());
    JLabel label = new JLabel("Display Name");
    JTextField text = new JTextField(20);
    text.setPreferredSize(new Dimension(20,25));
    c.add(label);
    c.add(text);
    global.add(c);
  
    //Hostname Field
    JPanel c1 = new JPanel();
    c1.setSize(100, 1);
    c1.setPreferredSize(new Dimension(100,1));
    c1.setLayout(new FlowLayout());
    JLabel label2 = new JLabel("Host Name");
    JTextField text1 = new JTextField(20);
    text1.setPreferredSize(new Dimension(20,25));
    c1.add(label2);
    c1.add(text1);
    global.add(c1);
  </code></pre>