Problems regarding JPanels in JPanels
We are working on a medium sized game in Java using Swing, and Model View Controller architecture.
Our JFrame Class is called GameRunner, which adds GameView to it's Content Pane, and then it validates and repaints.
GameView extends JPanel with a Y_AXIS BoxLayout and adds a WorldPanel and a HudPanel.
HudPanel extends Jpanel with a X_AXIS BoxLayout and adds a DescriptionPanel and a ActionPanel
DescriptionPanel extends JPanel with a X_AXIS BoxLayout and adds a JButton for testing.
ActionPanel extends JPanel with a X_AXIS BoxLayout and adds a JTextArea for testing.
WorldPanel extends JPanel, and overrides JPanel's paint method and uses it to paint a 2d array of images (Which represents our world in our game).
Inside the paint override, we set the size of the WorldPanel every single time it paints. Without that call, the WorldPanel defaults to a (0,0) Dimension for some ungodly reason.
So, our setSize in the paint fixed this problem (Or so we thought). We had it running perfectly inside of GameView before we added the HudPanel. However, when we did add the HudPanel to the GameView funny things occurred.
The HudPanel places itself at the very top of the GameView, as if there were no WorldPanel at all. The HudPanel stretches to fill all of GameView.
It might be worth mentioning that we do set the size of the HudPanel when we create it.