If jComponent is an instance of JEditorPane, we obtain a ClassCastException here. Moreover, getText() seems to be valid even on JTextComponent.