Inserting some red text inputfield.getDocument().insert(0, "my text", redAttributeSet); Send the text to the server Element root = inputfield.getDocument().getDefaultRootElement(); for(Element child :root.getElements()) int start = child.startoffset int end = child.endoffset AttributeSet attributes = child.getAttributes() for(AttributeSet attribute : attributes) if(attribute.hasforegroundcolor) text = jerklib.getColorCode(color) + inputfield.getDocument().getText(start, end)