private void addRoomsToFrameInGrid(ArrayList<Room> rooms, JPanel panel){
		panel.removeAll();
		
		if (!rooms.isEmpty()){
			Location first = rooms.get(0).getLocation();
			int minX, maxX;
			minX = maxX = first.getX();

			int minY, maxY;
			minY = maxY = first.getY();

			for (Room r: rooms){
				int curX = r.getLocation().getX();
				int curY = r.getLocation().getY();

				minX = Math.min(minX, curX);
				maxX = Math.max(maxX, curX);

				minY = Math.min(minY, curY);
				maxY = Math.max(maxY, curY);
			}

			int width = maxX - minX + 1;
			int height = maxY - minY + 1;

			GridLayout gridLayout = new GridLayout(height,width);
			panel.setLayout(gridLayout);

			Room[][] roomGrid = new Room[width][height];
			for (Room r: rooms){
				Location l = r.getLocation();

				roomGrid[l.getX()- minX][l.getY() - minY]  = r;
			}

			
			for (int j = height - 1; j >=0; j--){
				for (int i = 0; i < width; i++){
					if (roomGrid[i][j] != null){
						panel.add(new RoomPanel(roomGrid[i][j]));
					} else {
						panel.add(new JPanel());
					}
				}
			}

		}
		
	}