@Test public void testInsertTabAtPos() throws Exception { System.out.println("insertTabAtPos"); }
public void insertTabAtPos(int pos) throws BadLocationException { int distToLineBeginning = JTextPaneToolbox.getDistanceToClosestLineBeginning(pane, pos); int nextTabPos = 0; while(nextTabPos <= distToLineBeginning) { nextTabPos += spacesPerTab; } int distToNextTabPos = nextTabPos - distToLineBeginning; String spacesToInsert = ""; for(int i = 0; i < distToNextTabPos; ++i) spacesToInsert += " "; pane.getStyledDocument().insertString(pos, spacesToInsert, null); tabPositions.add(pos); }
TabInserter { public void insertTabAtPos(int pos) throws BadLocationException { int distToLineBeginning = JTextPaneToolbox.getDistanceToClosestLineBeginning(pane, pos); int nextTabPos = 0; while(nextTabPos <= distToLineBeginning) { nextTabPos += spacesPerTab; } int distToNextTabPos = nextTabPos - distToLineBeginning; String spacesToInsert = ""; for(int i = 0; i < distToNextTabPos; ++i) spacesToInsert += " "; pane.getStyledDocument().insertString(pos, spacesToInsert, null); tabPositions.add(pos); } }
TabInserter { public void insertTabAtPos(int pos) throws BadLocationException { int distToLineBeginning = JTextPaneToolbox.getDistanceToClosestLineBeginning(pane, pos); int nextTabPos = 0; while(nextTabPos <= distToLineBeginning) { nextTabPos += spacesPerTab; } int distToNextTabPos = nextTabPos - distToLineBeginning; String spacesToInsert = ""; for(int i = 0; i < distToNextTabPos; ++i) spacesToInsert += " "; pane.getStyledDocument().insertString(pos, spacesToInsert, null); tabPositions.add(pos); } TabInserter(JTextPane pane); }
TabInserter { public void insertTabAtPos(int pos) throws BadLocationException { int distToLineBeginning = JTextPaneToolbox.getDistanceToClosestLineBeginning(pane, pos); int nextTabPos = 0; while(nextTabPos <= distToLineBeginning) { nextTabPos += spacesPerTab; } int distToNextTabPos = nextTabPos - distToLineBeginning; String spacesToInsert = ""; for(int i = 0; i < distToNextTabPos; ++i) spacesToInsert += " "; pane.getStyledDocument().insertString(pos, spacesToInsert, null); tabPositions.add(pos); } TabInserter(JTextPane pane); void insertTabAtPos(int pos); void removeTabAtPos(int pos); int getSpacesPerTab(); void setAmountSpacesPerTab(int numberTabs); }
TabInserter { public void insertTabAtPos(int pos) throws BadLocationException { int distToLineBeginning = JTextPaneToolbox.getDistanceToClosestLineBeginning(pane, pos); int nextTabPos = 0; while(nextTabPos <= distToLineBeginning) { nextTabPos += spacesPerTab; } int distToNextTabPos = nextTabPos - distToLineBeginning; String spacesToInsert = ""; for(int i = 0; i < distToNextTabPos; ++i) spacesToInsert += " "; pane.getStyledDocument().insertString(pos, spacesToInsert, null); tabPositions.add(pos); } TabInserter(JTextPane pane); void insertTabAtPos(int pos); void removeTabAtPos(int pos); int getSpacesPerTab(); void setAmountSpacesPerTab(int numberTabs);  }