For some reason I am unable to add my secondary JPanel under the first one that I have. I am able to add the first JPanel with no errors, however when I try to add the second JPanel in the same way it does not work, and gives me a multitude of errors. I am not sure exactly what it is, but I am thinking it might either be how I am trying to put it into the frame, or because of the JFrame's layout. Here is the code for the secondary layout:
private MazeModel model;
public UIPanel(){
setPreferredSize(new Dimension(100, 100));
setBackground(Color.WHITE);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString("Moves taken: " + model.getMoveCounter(), 10, 0);
g.drawString("Current location: " + model.getPlayerX() + ", " + model.getPlayerY(), 10, 50);
}
Here is the frame here I am trying to add both the first main panel, as well as this new second one that is giving me trouble:
MazeView(){ //creating the JFrame and JPanel
model = new MazeModel();
panel = new MazePanel(model); //panel
player = new Player(model); //player class
//uipanel = new UIPanel();
controller = new MazeController(panel, model); //movement
this.setLayout(new BorderLayout()); //non null BorderLayout
this.setPreferredSize(new Dimension(500, 600));
addKeyListener(controller);
add(panel, BorderLayout.NORTH);
add(uipanel, BorderLayout.SOUTH);
this.pack();
I hope that I am providing enough code to help understand the issue I am having, if not just let me know. I still think it is something with the way I am adding it, and not the setup of the JPanel itself, but I could be wrong.