Java examples for Swing:Swing HTML
get Swing Document Text
import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.event.DocumentEvent; import javax.swing.text.Document; public class Main{ public static String getText(DocumentEvent e) { if (e == null) { throw new NullPointerException("e == null"); }/*from w w w .j a v a 2s . com*/ Document document = e.getDocument(); int length = document.getLength(); try { if (length > 0) { return document.getText(0, length); } } catch (Throwable t) { Logger.getLogger(DocumentUtil.class.getName()).log( Level.SEVERE, null, t); } return ""; } }