title: BorderLayout not working JFrame
body: <p>For some reason I can't get the <code>BorderLayout</code> to set the way it's supposed to. Just would like to know where I'm going wrong. </p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  
  import javax.swing.*;
  
  public class ColorFactory extends JFrame
  {
  
      final int width = 500;
      final int height = 300;
  
      private JPanel buttonPanel;
      private JPanel radioButtonPanel;
      private JLabel msgChangeColor;
  
      public ColorFactory()
      {
          setTitle("Color Factory");
          setSize(width, height);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          setLayout(new BorderLayout());
  
          createTopPanel();
          add(buttonPanel, BorderLayout.NORTH);
  
          createBottomPanel();
          add(radioButtonPanel, BorderLayout.SOUTH);
  
          msgChangeColor = new JLabel("Top buttons change the panel color and bottom radio buttons change the text color.");
          add(msgChangeColor, BorderLayout.CENTER);
  
          pack();
      }
  
      private void createTopPanel()
      {   
          buttonPanel = new JPanel();
          setLayout(new FlowLayout());
  
          JButton redButton = new JButton("Red");
          redButton.setBackground(Color.RED);
          redButton.addActionListener(new ButtonListener());
          redButton.setActionCommand("R");
  
          JButton orangeButton = new JButton("Orange");
          orangeButton.setBackground(Color.ORANGE);
          orangeButton.addActionListener(new ButtonListener());
          orangeButton.setActionCommand("O");
  
          JButton yellowButton = new JButton("Yellow");
          yellowButton.setBackground(Color.YELLOW);
          yellowButton.addActionListener(new ButtonListener());
          yellowButton.setActionCommand("Y");
  
          buttonPanel.add(redButton);
          buttonPanel.add(orangeButton);
          buttonPanel.add(yellowButton);
  
      }
  
      private void createBottomPanel()
      {
          radioButtonPanel = new JPanel();
          setLayout(new FlowLayout());
  
          JRadioButton greenRadioButton = new JRadioButton("Green");
          greenRadioButton.setBackground(Color.GREEN);
          greenRadioButton.addActionListener(new RadioButtonListener());
          greenRadioButton.setActionCommand("G");
  
          JButton blueRadioButton = new JButton("Blue");
          blueRadioButton.setBackground(Color.BLUE);
          blueRadioButton.addActionListener(new RadioButtonListener());
          blueRadioButton.setActionCommand("B");
  
          JButton cyanRadioButton = new JButton("Cyan");
          cyanRadioButton.setBackground(Color.CYAN);
          cyanRadioButton.addActionListener(new RadioButtonListener());
          cyanRadioButton.setActionCommand("C");
  
          radioButtonPanel.add(greenRadioButton);
          radioButtonPanel.add(blueRadioButton);
          radioButtonPanel.add(cyanRadioButton);
      }
  
      private class ButtonListener implements ActionListener
      {
          public void actionPerformed(ActionEvent e)
          {
              String actionColor = e.getActionCommand();
              if(actionColor.equals("R"))
              {
                  buttonPanel.setBackground(Color.RED);
                  radioButtonPanel.setBackground(Color.RED);
              }
  
              if(actionColor.equals("O"))
              {
                  buttonPanel.setBackground(Color.ORANGE);
                  radioButtonPanel.setBackground(Color.ORANGE);
              }
  
              if(actionColor.equals("Y"))
              {
                  buttonPanel.setBackground(Color.YELLOW);
                  radioButtonPanel.setBackground(Color.YELLOW);
              }
          }
      }
          private class RadioButtonListener implements ActionListener
          {
              public void actionPerformed(ActionEvent e)
              {
                  String actionTextColor = e.getActionCommand();
                  if(actionTextColor.equals("G"))
                  {
                      msgChangeColor.setForeground(Color.GREEN);
                  }
  
                  if(actionTextColor.equals("B"))
                  {
                      msgChangeColor.setForeground(Color.BLUE);
                  }
  
                  if(actionTextColor.equals("C"))
                  {
                      msgChangeColor.setForeground(Color.CYAN);
                  }
              }
      }
  
          public static void main(String[] args)
          {
              ColorFactory run = new ColorFactory();
              run.setVisible(true);
          }
  
  }
  </code></pre>