I am working on hotel management software for class and I am running into a few issues with my code. At this point, I am simply trying to add a JPanel I created in a separate cl
jpanel.add("Room", room.getRoomPanel());
You've never initialized room
RoomSystem room;
Even if you do initialize it RoomSystem room = new RoomSystem()
, you still have another problem in your RoomSystem
class. You have shadowed roomPanel
, and therefore the class member is null, when you try and call getRoomPanel()
. In your constructor, change
// shadowing the class field roomPanel
JPanel roomPanel = new JPanel(new FlowLayout());
to
roomPanel = new JPanel(new FlowLayout());