You could try sub-classing DefaultStyledDocument and overriding insert to replace any tabs in the inserted elements with spaces. Then install your sub-class in JTextPane with setStyledDocument(). This may be more trouble than catching key events though.