StringBuffer buf = new StringBuffer(); for(int i = buffer.getTabSize(); i > 0; i--) { buf.append(' '); } textArea.replaceSelection(buf.toString());
Element map = buffer.getDefaultRootElement(); Element lineElement = map.getElement(map.getElementIndex( selStart));  try { String line = buffer.getText(lineElement .getStartOffset(),selStart - lineElement.getStartOffset());  textArea.replaceSelection(createSoftTab(line, buffer.getTabSize())); } catch(BadLocationException bl) { bl.printStackTrace(); }
        public void actionPerformed(ActionEvent evt)        {                View view = getView(evt);                Buffer buffer = view.getBuffer();                JEditTextArea textArea = view.getTextArea();                Mode mode = buffer.getMode();		int selStart = textArea.getSelectionStart();		int selEnd = textArea.getSelectionEnd();                if(selStart == selEnd			&& "on".equals(buffer.getProperty("indentOnTab"))			&& mode.indentLine(buffer,view,selStart))                {				return;                }                if("yes".equals(buffer.getProperty("noTabs")))                {                        StringBuffer buf = new StringBuffer();                        for(int i = buffer.getTabSize(); i > 0; i--)                        {                                buf.append(' ');                        }                        textArea.replaceSelection(buf.toString());                }                else                        textArea.replaceSelection("\t");        }