I'm trying to make an array of buttons go inside of a JPanel. From there, I want the JPanel to be added to a JScrollPane so if there are more buttons that are needed, I will be able to scroll through all of the buttons as the app scales in size. However, after compiling, the JPanel is fine and will render all 10 buttons fine. Then the trouble begins, once I add the JPanel to the JScrollPane, the entire JScrollPane is completely blank.
cMain.challengeModePanel = new JPanel(new GridLayout(10,1));
cMain.challengeModePanel.setBackground(Color.black);
cMain.challengeModePanel.setForeground(Color.white);
cMain.challengeModePanel.setVisible(true);
//panelConfiguration(cMain.challengeModePanel, 175, 240, 250, 250, Color.black, 10,1, cMain.window);
//The button generator method below was created by me to quickly add features to a button such as foreground, background, handlers and the panel it is going to be added to
for (int i = 0; i < 10; i++) {
cMain.challengeModeButtons[i] = new JButton();
buttonGenerator(cMain.challengeModeButtons[i], cMain.font3, Color.black, Color.white, false, cMain.clickerHandler, "StartMenu", cMain.mouseHandler, cMain.challengeModePanel);
cMain.challengeModeButtons[i].setSize(100, 50);
cMain.challengeModePanel.add(cMain.challengeModeButtons[i]);
}
cMain.challengeModeScrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
cMain.challengeModeScrollPane.setColumnHeaderView(new JLabel("Challenges:"));
cMain.challengeModeScrollPane.setBackground(Color.black);
cMain.challengeModeScrollPane.setForeground(Color.white);
cMain.challengeModeScrollPane.add(cMain.challengeModePanel);
cMain.challengeModeScrollPane.setBounds(130, 180, 200, 300);
cMain.challengeModeScrollPane.setVisible(true);
cMain.window.add(cMain.challengeModeScrollPane);
I was expecting the program to render the buttons at the size they were set in within the code. From there, I was hoping that that JPanel would go inside of the JScrollPane and allow me to view it in a smaller area with the ability to scroll through all of the buttons akin to a JTextArea. However, as mentioned above, the JScrollPane is only rendering a blank pane with a vertical scroll and horizontal scroll bar.