public void setText(String text) { if (text == null) throw new IllegalArgumentException("text cannot be null."); BitmapFont font = style.font; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < text.length(); i++) { if (maxLength > 0 && buffer.length() + 1 > maxLength) { break; } char c = text.charAt(i); if (font.containsCharacter(c) && (filter == null || filter.acceptChar(this, c))) buffer.append(c); } this.text = buffer.toString(); updateDisplayText(); cursor = 0; clearSelection(); textBounds.set(font.getBounds(displayText)); textBounds.height -= font.getDescent() * 2; font.computeGlyphAdvancesAndPositions(displayText, glyphAdvances, glyphPositions); }