I want to know how to make visible components added to a JPanel that happens to be inside a JScrollPane after the JFrame has already been created. My class, that extends JFrame, has the jbInit() method you see below. At the very end of the jbInit() method I set up cardPanel to a GridLayout of 10 rows 1 column. This is so that I can display up to 10 distinct components as I add them dynamically using the displayResults() method. As you can imagine, the new HandStats (which extend JPanel) if they are being added to cardPanel, are not being displayed. I've tried using repaint() methods but they don't do anything. How do I accomplish this? Also, how do I remove the HandStats objects from cardPanel so that I can display another new set of them?
Maybe I've just been at work too long today, I'm not too comfortable with this solution. I got this to work by adjusting the viewPortView() of the scrollPane after I added the extra components.
Here is a complete listing. I hope it helps you out.
Just copy and past it.
Joined: Sep 29, 2004
Well, I guess I should tell you how to execute it.
Run it, and it will start with a handful of components on a Panel. In the File Menu up top, there is an "Add" option that will add a handful of additional components to that panel. [ November 02, 2004: Message edited by: jefff willis ]