@Test public void testGetCharToTheRightOfCaret() { JTextPane pane = new JTextPane(); pane.setText("abc"); pane.setCaretPosition(0); String rhs = JTextPaneToolbox.getCharToTheRightOfCaret(pane); assertEquals("a", rhs); pane.setCaretPosition(1); rhs = JTextPaneToolbox.getCharToTheRightOfCaret(pane); assertEquals("b", rhs); pane.setCaretPosition(2); rhs = JTextPaneToolbox.getCharToTheRightOfCaret(pane); assertEquals("c", rhs); pane.setCaretPosition(3); rhs = JTextPaneToolbox.getCharToTheRightOfCaret(pane); assertEquals("", rhs); }
public static String getCharToTheRightOfCaret(JTextPane pane) { String code = getText(pane); int caretPos = pane.getCaretPosition(); if(caretPos == code.length()) return ""; else { return code.substring(caretPos, caretPos + 1); } }
JTextPaneToolbox { public static String getCharToTheRightOfCaret(JTextPane pane) { String code = getText(pane); int caretPos = pane.getCaretPosition(); if(caretPos == code.length()) return ""; else { return code.substring(caretPos, caretPos + 1); } } }
JTextPaneToolbox { public static String getCharToTheRightOfCaret(JTextPane pane) { String code = getText(pane); int caretPos = pane.getCaretPosition(); if(caretPos == code.length()) return ""; else { return code.substring(caretPos, caretPos + 1); } }  }
JTextPaneToolbox { public static String getCharToTheRightOfCaret(JTextPane pane) { String code = getText(pane); int caretPos = pane.getCaretPosition(); if(caretPos == code.length()) return ""; else { return code.substring(caretPos, caretPos + 1); } }  static String getText(JTextPane pane); static int getDistanceToClosestLineBeginning(JTextPane pane, int pos); static int transformToLineNumber(JTextPane pane, int absPos); static int transformToLineNumber(String code, int absPos); static int getLineBeginning(JTextPane pane, int line); static int getClosestLineBeginningAfter(JTextPane pane, int absPos); static ArrayList<Integer> getLinesBetween(JTextPane pane, int start, int end); static String getCharToTheLeftOfCaret(JTextPane pane); static String getCharToTheRightOfCaret(JTextPane pane); static int getFirstCharPosInLine(JTextPane pane, int line); static int getWordBeginningAtCursor(JTextPane pane); }
JTextPaneToolbox { public static String getCharToTheRightOfCaret(JTextPane pane) { String code = getText(pane); int caretPos = pane.getCaretPosition(); if(caretPos == code.length()) return ""; else { return code.substring(caretPos, caretPos + 1); } }  static String getText(JTextPane pane); static int getDistanceToClosestLineBeginning(JTextPane pane, int pos); static int transformToLineNumber(JTextPane pane, int absPos); static int transformToLineNumber(String code, int absPos); static int getLineBeginning(JTextPane pane, int line); static int getClosestLineBeginningAfter(JTextPane pane, int absPos); static ArrayList<Integer> getLinesBetween(JTextPane pane, int start, int end); static String getCharToTheLeftOfCaret(JTextPane pane); static String getCharToTheRightOfCaret(JTextPane pane); static int getFirstCharPosInLine(JTextPane pane, int line); static int getWordBeginningAtCursor(JTextPane pane);  }