@Override
    public void draw(Graphics2D g) {
        super.draw(g);

        if (!isVisible()) return;

        Rectangle2D titleBounds = TITLE_FONT.getStringBounds(title, g.getFontRenderContext());

        //double menuWidth = titleBounds.getWidth();
        double menuHeight = titleBounds.getHeight();

        for (int i = 0; i < items.size(); i++) {
            items.get(i).bounds = ITEM_FONT.getStringBounds(items.get(i).text, g.getFontRenderContext());
            menuHeight += items.get(i).bounds.getHeight();
            //menuWidth = Math.max(menuWidth, bounds.getWidth());
        }

        double menuStartY = getHeight() / 2 - menuHeight / 2;

        g.setFont(TITLE_FONT);
        g.setColor(TITLE_COLOR);
        g.drawString(title, getWidth() / 2 - (float) titleBounds.getWidth() / 2,
                            (float) menuStartY);

        for (int i = 0; i < items.size(); i++) {
            Rectangle2D bounds = items.get(i).bounds;
            menuStartY += bounds.getHeight();

            g.setFont(ITEM_FONT);
            double rectYAdd = bounds.getHeight() - 5;
            bounds.setRect(getWidth() / 2 - bounds.getWidth() / 2, menuStartY - rectYAdd, bounds.getWidth() + 1, bounds.getHeight());

            if (hoverIndex == i || (hoverIndex == -1 && currentItem == i)) {
                if (clickIndex == currentItem) g.setColor(ITEM_CLICKED_COLOR);
                else g.setColor(ITEM_SELECTED_COLOR);
                g.draw(items.get(i).bounds);
            }
            else g.setColor(ITEM_COLOR);
            g.drawString(items.get(i).text, (float) bounds.getX(), (float) (bounds.getY() + rectYAdd));
        }
    }