/** * Converts all instances of a number of spaces equal to a tab size * into a tab in this text area. * * @see #convertTabsToSpaces * @see #getTabsEmulated * @see #setTabsEmulated */ public void convertSpacesToTabs() { // FIXME: This is inefficient and will yield an OutOfMemoryError if // done on a large document. We should scan 1 line at a time and // replace; it'll be slower but safer. int caretPosition = getCaretPosition(); int tabSize = getTabSize(); StringBuilder stringBuilder = new StringBuilder(); for (int i=0; i<tabSize; i++) { stringBuilder.append(" "); } String text = getText(); setText(text.replaceAll(stringBuilder.toString(), "\t")); int newDocumentLength = getDocument().getLength(); // Place the caret back in its proper position. if (caretPosition<newDocumentLength) { setCaretPosition(caretPosition); } else { setCaretPosition(newDocumentLength-1); } }
/** * Converts all instances of a number of spaces equal to a tab size * into a tab in this text area. * * @see #convertTabsToSpaces * @see #getTabsEmulated * @see #setTabsEmulated */ public void convertSpacesToTabs() { // FIXME: This is inefficient and will yield an OutOfMemoryError if // done on a large document. We should scan 1 line at a time and // replace; it'll be slower but safer. int caretPosition = getCaretPosition(); int tabSize = getTabSize(); StringBuilder stringBuilder = new StringBuilder(); for (int i=0; i<tabSize; i++) { stringBuilder.append(" "); } String text = getText(); setText(text.replaceAll(stringBuilder.toString(), "\t")); int newDocumentLength = getDocument().getLength(); // Place the caret back in its proper position. if (caretPosition<newDocumentLength) { setCaretPosition(caretPosition); } else { setCaretPosition(newDocumentLength-1); } }
/** * Converts all instances of a number of spaces equal to a tab size * into a tab in this text area. * * @see #convertTabsToSpaces * @see #getTabsEmulated * @see #setTabsEmulated */ public void convertSpacesToTabs() { // FIXME: This is inefficient and will yield an OutOfMemoryError if // done on a large document. We should scan 1 line at a time and // replace; it'll be slower but safer. int caretPosition = getCaretPosition(); int tabSize = getTabSize(); String tabInSpaces = ""; for (int i=0; i<tabSize; i++) tabInSpaces += " "; String text = getText(); setText(text.replaceAll(tabInSpaces, "\t")); int newDocumentLength = getDocument().getLength(); // Place the caret back in its proper position. if (caretPosition<newDocumentLength) setCaretPosition(caretPosition); else setCaretPosition(newDocumentLength-1); }
/** * Converts all instances of a number of spaces equal to a tab size * into a tab in this text area. * * @see #convertTabsToSpaces * @see #getTabsEmulated * @see #setTabsEmulated */ public void convertSpacesToTabs() { // FIXME: This is inefficient and will yield an OutOfMemoryError if // done on a large document. We should scan 1 line at a time and // replace; it'll be slower but safer. int caretPosition = getCaretPosition(); int tabSize = getTabSize(); String tabInSpaces = ""; for (int i=0; i<tabSize; i++) tabInSpaces += " "; String text = getText(); setText(text.replaceAll(tabInSpaces, "\t")); int newDocumentLength = getDocument().getLength(); // Place the caret back in its proper position. if (caretPosition<newDocumentLength) setCaretPosition(caretPosition); else setCaretPosition(newDocumentLength-1); }
Document doc = getDocument(); if (doc!=null) { Element map = doc.getDefaultRootElement();
Document doc = getDocument(); if (doc!=null) { Element map = doc.getDefaultRootElement();