public final void setText(String text){
        width = maxwidth;
        String[] a = text.split("\n");
        LinkedList<String> temp = new LinkedList<>();
        
        for(String s : a){
            temp.add("");
            int w = 0;
            String[] b = s.split(" ");
            
            for(String ss : b){
                int wordwidth = TextRenderHelper.getWidth((w == 0 ? "" : " ") + ss);
                if(w + wordwidth > width){
                    w = wordwidth;
                    temp.add(ss);
                }else{
                    temp.add(temp.removeLast() + (w == 0 ? "" : " ") + ss);
                    w += wordwidth;
                }
            }
        }
        int maxw = 0;
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for(String s : temp){
            int w = TextRenderHelper.getWidth(s);
            if(w > maxw){
                maxw = w;
            }
            if(!first){
                sb.append('\n');
            }
            first = false;
            sb.append(s);
        }
        this.text = sb.toString();
        width = Math.max(maxw, minwidth);
        height = temp.size() * charHeight;
    }