Point pt = c.modelToView(offs+1).getLocation();
Point pt = null;       try {  pt = c.modelToView(offs+1).getLocation(); } catch(BadLocationException ble) { return offset; }
  public static final int getPositionBelow(JTextComponent c, int offset, int x)    throws BadLocationException  {    int offs = getRowEnd(c, offset);        if(offs == -1)      return -1;    // Effectively calculates the y value of the previous line.    Point pt = c.modelToView(offs+1).getLocation();        pt.x = x;        // Calculate a simple fitting offset.    offs = c.viewToModel(pt);        if (offs == c.getDocument().getLength())      return offs;        // Find out the real x positions of the calculated character and its    // neighbour.    int offsX = c.modelToView(offs).getLocation().x;    int offsXNext = c.modelToView(offs+1).getLocation().x;        // Chose the one which is nearer to us and return its offset.    if (Math.abs(offsX-x) <= Math.abs(offsXNext-x))      return offs;    else      return offs+1;  }