private String wrapText(String text) {
        int spaceSpace = GenericLabel.getStringWidth(" ");
        int spaceAvailable = getWidth();
        int spaceRemaining = spaceAvailable;
        String[] words = text.split(" ");
        String result = "";

        for (int i = 0; i < words.length; i++) {
            int wordSpace = GenericLabel.getStringWidth(words[i]);

            if (!result.isEmpty() && wordSpace > spaceRemaining) {
                result += "\n";
                spaceRemaining = spaceAvailable;
            }
            result += words[i];
            spaceRemaining -= wordSpace;
            if (spaceSpace > spaceRemaining) {
                result += "\n";
                spaceRemaining = spaceAvailable;
            } else {
                result += " ";
                spaceRemaining -= spaceSpace;
            }
        }
        return result;
    }