When you call...
panel1.add(gameDisplay);
panel1.add(displayScroll);
You are effectively removing the gameDisplay
from displayScroll
, as a component can only have one parent.
The fact that it works as it does comes down to the fact that you are playing around with the position and size of the gameDisplay
panel instead of the displayScroll
, which you should be...
Use
panel1.add(displayScroll);
Instead, but make sure you size and position ONLY the displayScroll
, as displayScroll
will take care of the gameDisplay