I am using a JPanel to hold around 100 buttons. The JPanel is using GridLayout to organise these buttons in rows of 3 buttons per row. i.e.
buttonPanel.setLayout(new GridLayout(33,3));
As there are so many buttons they obviously don't all fit in the viewable area of the screen. To get around this I am trying to use a JScrollPane on the buttonPanel to make it scroll but I can't get it to work. I have tried both creating a seperate JScrollPane object and adding the buttonPanel to it
JScrollPane buttonScroll = new JScrollPane();
buttonPanel.setLayout(new GridLayout(33,3));
buttonPanel.setPreferredSize(new Dimension(380,400));
buttonPanel.setMaximumSize(new Dimension(380,400));
buttonScroll.add(buttonPanel);
and also embeding everything into a new JPanel like:
buttonHolder.add(new JScrollPane(buttonPanel),BorderLayout.CENTER);
Neither way works. Any ideas. I've read about view port but not exactly sure what this is or if this will fix my problem.
Help urgently required.