/** Returns the the Token at pos as a String */ public static String getTokenStringAt(SyntaxDocument doc, int pos) { String word = ""; Token t = doc.getTokenAt(pos); if (t != null) { try { word = doc.getText(t.start, t.length); } catch (BadLocationException ex) { Logger.getLogger(ActionUtils.class.getName()).log(Level.SEVERE, null, ex); } } return word; }