Dynamically create list of jpanels swing/java

arxdalad

New Member
I am attempting to create panel, PluginListPanel (extending JPanel), which will show a list of plugin panels which will respect the preferred height of the plugin's panel, but will force the width. I have a solution, but it is slow and has a weird bug. In the screenshot, there are two such panels, one to the left and one to the right:
hDDsW.png
I don't know different layout manager systems very well, but I know that the TOP field in the BorderLayout does what I want. So, I came up with this 'recursive' solution:\[code\]public PluginListPanel(List<PanelContainer> items) { JPanel body = this; for (PanelContainer item : items) { body.setLayout(new BorderLayout(0, 0)); JPanel panel = new PluginOnePanel(item); body.add(panel, BorderLayout.NORTH); JPanel newBody = new JPanel(); body.add(newBody, BorderLayout.CENTER); body = newBody; }}\[/code\]The problem I encounter is when I scroll, the system responds somewhat slowly, and the colour of the SamplePluginPanels is different (see picture below), even if the number of SamplePluginPanels is as low as 8.The question is, how can I make this more elegant, not slow down the program and not miscolour the panels?Any insights are highly appreciated.
736qv.png
 
Top