I have made an array of JButtons arranged in a 2x3 box encased in a JPanel with GridLayout. This works fine. But i want to add a JLabel with text under this panel. Problem is that the JLabel, represented here by itemsInfo will not show, and I can't figgure it out why. Also I want to include the first panel and this JLabel in a second Panel, called wholeItems. Please help. And yes I know that GridLayout on the second Panel is not desirable. But it still doesn't show the JLabel.
Code below:
for(int i=0; i<items.length; i++) {
items[i] = new JButton();
items[i].setPreferredSize(new Dimension(50, 50));
items[i].setBackground(new Color(220, 140, 10));
itemsPanel.add(items[i]);
}
itemsInfo = new JLabel("abc");
itemsInfo.setBackground(new Color(230, 50, 60));
wholeItems = new JPanel();
wholeItems.setLayout(new GridLayout(2,1));
wholeItems.add(itemsPanel);
wholeItems.add(itemsInfo);