title: Is there any way for me to make BorderLayout's east, south and west border bigger?
body: <p>I've been writing the code for a periodic table's GUI. I have everything looking fine, however the many buttons I've added to the East, West and South borders (metals, non metals and lanthanides) have a &quot;...&quot; as their button's text as opposed to the Element Symbol like the center (transition metals). This is due to the fact that the buttons in East, South and West are being crammed into their respective border when I do <code>frame.pack()</code>. Is there any way I can make these borders slightly bigger so the buttons will be less crammed and thus display their intended title as opposed to &quot;...&quot;? I've tried changing the frame size and the preferred button size of each button (Lines 14 and 137) but the <code>pack()</code> method seems to be overriding this.</p>
  <pre><code>public class TestLayout
  {
   public static void main (String[] args)
   {          
        JFrame window = new JFrame();
        JPanel mainPanel = new JPanel();
        
        window.setTitle (&quot;Panda Productions: Periodic Table&quot;);
        window.setSize(1700, 1200);
        window.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        window.setContentPane(mainPanel);
        window.setResizable(false);
        
        JPanel toggle = new JPanel();
        toggle.setBorder(BorderFactory.createTitledBorder(&quot;Enable Subshell View:&quot;));
        toggle.setPreferredSize(new Dimension(200, 100));
        JPanel legend = new JPanel();
        legend.setBorder(BorderFactory.createTitledBorder(&quot;Legend:&quot;));
        JLabel programTitle = new JLabel(&quot;    Periodic Table of The Elements    &quot;);
        programTitle.setFont(new Font(&quot;Century Gothic&quot;, Font.BOLD, 36));
        JLabel errorInfo = new JLabel(&quot;                                  Please Select/Search for an Element...&quot;);
        errorInfo.setFont(new Font(&quot;Century Gothic&quot;, Font.BOLD, 14));
        JLabel legendLabel = new JLabel();
        legendLabel.setText(convertToMultiline(&quot;&lt;font color='fuchsia'&gt;Pink = Noble Gas&lt;/font&gt;  &lt;html&gt;&lt;font color='red'&gt;Red = Alkali Metals&lt;/font&gt;  &lt;font color='blue'&gt;Blue = Alkaline Earth&lt;/font&gt;  &lt;font color='Green'&gt;Green = Transition Metal&lt;/font&gt; \n&lt;font color='yellow'&gt;Yellow = Lanthanide/Actinide&lt;/font&gt;  &lt;font color='orange'&gt;Orange = Metal&lt;/font&gt;  &lt;font color='gray'&gt;Gray = Non-Metal&lt;/font&gt;  &lt;font color='purple'&gt;Purple = Halogen&lt;/font&gt;  &lt;font color='aqua'&gt;Cyan = Metalloid&lt;/font&gt;&quot;));
        JTextField elementInput = new JTextField ();
        JTextField atomicNumInput = new JTextField ();
        JCheckBox viewToggle = new JCheckBox();
        JButton searchButton1 = new JButton(&quot;Search for Name&quot;);
        JButton searchButton2 = new JButton(&quot;Search for Atomic #&quot;); 
        
        BorderLayout border = new BorderLayout();
        
        BorderLayout topGrid = new BorderLayout();
        GridLayout bottomGrid = new GridLayout(1,3);
        
        JPanel transitionLegendPanel = new JPanel();
        BoxLayout transitionLegend = new BoxLayout(transitionLegendPanel, BoxLayout.Y_AXIS);
        
        JPanel userInputPanel = new JPanel();
        userInputPanel.setPreferredSize(new Dimension(320, 100));
        userInputPanel.setBorder(BorderFactory.createTitledBorder(&quot;Search by Element Name or Atomic #:&quot;));
        GridLayout userInput = new GridLayout(2,2);
        
        JPanel titlePanel = new JPanel();
        BoxLayout titleLayout = new BoxLayout (titlePanel, BoxLayout.Y_AXIS);
        
        GridLayout metalsLayout = new GridLayout(7,2);
        GridLayout nonMetalsLayout = new GridLayout(7,6);
        GridLayout transitionMetalsLayout = new GridLayout(4,10);
        GridLayout lanthanidesLayout = new GridLayout(2,15);
        
        JPanel topGridPanel = new JPanel();
        JPanel bottomGridPanel = new JPanel();
        JPanel lanthanidesPanel = new JPanel();
        JPanel metalsPanel = new JPanel();
        JPanel nonMetalsPanel = new JPanel();
        JPanel transitionMetalsPanel = new JPanel();
   
        mainPanel.setLayout(border);
        topGridPanel.setLayout(topGrid);
        bottomGridPanel.setLayout(bottomGrid);
        mainPanel.add(topGridPanel, BorderLayout.NORTH);
        mainPanel.add(bottomGridPanel, BorderLayout.SOUTH);
        
        metalsPanel.setLayout(metalsLayout);
        nonMetalsPanel.setLayout(nonMetalsLayout);
        mainPanel.add(metalsPanel, BorderLayout.WEST);
        mainPanel.add(nonMetalsPanel, BorderLayout.EAST);
  
        transitionLegendPanel.setLayout(transitionLegend);
        mainPanel.add(transitionLegendPanel, BorderLayout.CENTER);
        
        userInputPanel.setLayout(userInput);
        titlePanel.setLayout(titleLayout);
        topGridPanel.add(userInputPanel, BorderLayout.WEST);
        topGridPanel.add(titlePanel, BorderLayout.CENTER);
        topGridPanel.add(toggle, BorderLayout.EAST);
        
        bottomGridPanel.add(new JLabel(&quot;&quot;));
        lanthanidesPanel.setLayout(lanthanidesLayout);
        bottomGridPanel.add(lanthanidesPanel);
        bottomGridPanel.add(new JLabel(&quot;&quot;));
        
        userInputPanel.add(elementInput);
        userInputPanel.add(searchButton1);
        userInputPanel.add(atomicNumInput);
        userInputPanel.add(searchButton2);
        
        titlePanel.add(programTitle);
        titlePanel.add(errorInfo);
        toggle.add(viewToggle);
        legend.add(legendLabel);
        transitionLegendPanel.add(legend);
        transitionLegendPanel.add(Box.createRigidArea(new Dimension(0,5)));
        transitionMetalsPanel.setLayout(transitionMetalsLayout);
        transitionLegendPanel.add(transitionMetalsPanel);
        
        BufferedReader reader = null;
        ElementsTest[] element = new ElementsTest[118];
        
        try {
             File file = new File(&quot;Elements.txt&quot;);
             reader = new BufferedReader(new FileReader(file));
             
             for (int counter = 0 ; counter &lt; 118 ; counter++)
             {
                  String name = reader.readLine();
                  int atomicNum = counter + 1;
                  String atomicWeight = reader.readLine();
                  String elementSymbol = reader.readLine();
                  String elementCharge = reader.readLine();
                  String fullElectronConfig = reader.readLine();
                  String shortElectronConfig = reader.readLine();
                  String elementState = reader.readLine();
                  String elementType = reader.readLine();
                  String density = reader.readLine();
                  String meltingPoint = reader.readLine();
                  String boilingPoint = reader.readLine();
                  String emptyLine = reader.readLine();
                  
                  element[counter] = new ElementsTest (name, atomicNum,  atomicWeight, elementSymbol, elementCharge, fullElectronConfig, shortElectronConfig, elementState, elementType, density, meltingPoint, boilingPoint);
             }
             
        } catch (IOException e) {
             e.printStackTrace();
        }             
        
        JButton[] buttonArray = new JButton[118];
        for (int i = 0 ; i &lt; 118 ; i++)
        {
             buttonArray[i] = new JButton();
             buttonArray[i].setPreferredSize(new Dimension(10, 10));
        }
             
        for (int counter2 = 0 ; counter2 &lt; 118 ; counter2++)
        {
             String currentSymbol = element[counter2].getElementSymbol();
             buttonArray[counter2].setText(currentSymbol);
             
             if (element[counter2].getElementType().equals(&quot;Metal&quot;))
             {
                 buttonArray[counter2].setBackground(Color.ORANGE);
                 buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Non-Metal&quot;))
             {
                  buttonArray[counter2].setBackground(Color.GRAY);
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Noble Gas&quot;))
             {
                  buttonArray[counter2].setBackground(Color.PINK);
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Transition Metal&quot;))
             {
                  buttonArray[counter2].setBackground(new Color(17, 131, 14));
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Lanthanide&quot;))
             {
                  buttonArray[counter2].setBackground(Color.YELLOW);
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Alkali Metal&quot;))
             {
                  buttonArray[counter2].setBackground(Color.RED);
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Alkaline Earth Metal&quot;))
             {
                  buttonArray[counter2].setBackground(Color.BLUE);
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Halogen&quot;))
             {
                  buttonArray[counter2].setBackground(new Color(173, 91, 255));
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Metalloid&quot;))
             {
                  buttonArray[counter2].setBackground(Color.CYAN);
                  buttonArray[counter2].setOpaque(true);
             }
             
             if (element[counter2].getElementType().equals(&quot;Actinide&quot;))
             {
                  buttonArray[counter2].setBackground(Color.YELLOW);
                  buttonArray[counter2].setOpaque(true);
             }
             
             else {
                  buttonArray[counter2].setOpaque(true);
             }
        }
  
        metalsPanel.add(buttonArray[0]);
        metalsPanel.add(new JButton(&quot;&quot;));
        metalsPanel.add(buttonArray[2]);
        metalsPanel.add(buttonArray[3]);
        metalsPanel.add(buttonArray[10]);
        metalsPanel.add(buttonArray[11]);
        metalsPanel.add(buttonArray[18]);
        metalsPanel.add(buttonArray[19]);
        metalsPanel.add(buttonArray[36]);
        metalsPanel.add(buttonArray[37]);
        metalsPanel.add(buttonArray[54]);
        metalsPanel.add(buttonArray[55]);
        metalsPanel.add(buttonArray[86]);
        metalsPanel.add(buttonArray[87]);
        
        for (int x = 20 ; x &lt; 30 ; x++)
        {
             transitionMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 38 ; x &lt; 48 ; x++)
        {
             transitionMetalsPanel.add(buttonArray[x]);
        }
        
        transitionMetalsPanel.add(new JButton(&quot;57-71&quot;));
        
        for (int x = 71 ; x &lt; 80 ; x++)
        {
             transitionMetalsPanel.add(buttonArray[x]);
        }
        
        transitionMetalsPanel.add(new JButton(&quot;89-103&quot;));
        
        for (int x = 103 ; x &lt; 112 ; x++)
        {
             transitionMetalsPanel.add(buttonArray[x]);
        }
        
        nonMetalsPanel.add(new JButton(&quot;&quot;));
        nonMetalsPanel.add(new JButton(&quot;&quot;));
        nonMetalsPanel.add(new JButton(&quot;&quot;));
        nonMetalsPanel.add(new JButton(&quot;&quot;));
        nonMetalsPanel.add(new JButton(&quot;&quot;));
        nonMetalsPanel.add(buttonArray[1]);
        
        for (int x = 4 ; x &lt; 10 ; x++)
        {
             nonMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 12 ; x &lt; 18 ; x++)
        {
             nonMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 30 ; x &lt; 36 ; x++)
        {
             nonMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 48 ; x &lt; 54 ; x++)
        {
             nonMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 80 ; x &lt; 86 ; x++)
        {
             nonMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 112 ; x &lt; 118 ; x++)
        {
             nonMetalsPanel.add(buttonArray[x]);
        }
        
        for (int x = 56 ; x &lt; 71 ; x++)
        {
             lanthanidesPanel.add(buttonArray[x]);
        }
        
        for (int x = 88 ; x &lt; 103 ; x++)
        {
             lanthanidesPanel.add(buttonArray[x]);
        }
        
                  window.pack();
        window.setVisible (true);
   }
   
   public static String convertToMultiline(String orig)
   {
        return &quot;&lt;html&gt;&quot; + orig.replaceAll(&quot;\n&quot;, &quot;&lt;br&gt;&quot;);
   }
  }
  </code></pre>
  <p>Current GUI Output:
  <img src="https://i.imgur.com/SZbcR6O.png" alt="GUI Current Output" /></p>