@Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        int currentY = 0;
        for (AccordionRootItem menu : getMenus()) {
            menu.setSize(this.getWidth(), this.menusSize);
            menu.setLocation(0, currentY);

            if (menu == lastSelectedMenu && !menu.isSelected()) {
                currentY += this.menusSize;
                menu.getBranchPanel().setSize(this.getWidth(), this.hidingSize);
                menu.getBranchPanel().setLocation(0, currentY);
                currentY += this.hidingSize;
            }
            if (menu.isSelected()) {
                currentY += this.menusSize;
                menu.getBranchPanel().adjustItems(freeAvaiableRows);
                menu.getBranchPanel().setSize(this.getWidth(), this.showingSize);
                menu.getBranchPanel().setLocation(0, currentY);
                currentY += this.showingSize;
            } else if (!menu.isSelected() && menu != lastSelectedMenu) {
                menu.getBranchPanel().setSize(0, 0);
                currentY += this.menusSize;
            }
        }
        update();
    }