Hi. I'm very new to Java so this is a beginner question. I'm using a JScrollPane to view a large rectangle (a JPanel I'm calling gamepanel) in a smaller JFrame. My JDK version is 1.6.0_24 and I'm running my program locally from a JAR file.
The problem is that some of time, the "gamepanel" object and scroll bars are visible when the program runs and sometimes the screen shows a gray background with no scroll bars. It seems to be equally likely that I'll see the gamepanel or the gray background when the program runs. If it's the gray background, I can resize the JFrame and the gamepanel and scroll bars will immediately appear. If I skip the JScrollPane and add the gamepanel directly to the JFrame, I never see the gray background.
How can I adjust the way I'm using JScrollPane so that the gamepanel and scrollbars are always shown in the JScollPane when the program runs?
Thanks for your help. Here's a simplified version of my code: