Index: javax/swing/plaf/basic/BasicTextUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v retrieving revision 1.43 diff -u -r1.43 BasicTextUI.java --- javax/swing/plaf/basic/BasicTextUI.java 30 Sep 2005 19:54:18 -0000 1.43 +++ javax/swing/plaf/basic/BasicTextUI.java 11 Oct 2005 18:31:15 -0000 @@ -973,7 +973,7 @@ */ public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn) { - return 0; // FIXME: Implement me. + return rootView.viewToModel(pt.x, pt.y, getVisibleEditorRect(), biasReturn); } /** Index: javax/swing/text/DefaultCaret.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultCaret.java,v retrieving revision 1.16 diff -u -r1.16 DefaultCaret.java --- javax/swing/text/DefaultCaret.java 4 Oct 2005 15:14:33 -0000 1.16 +++ javax/swing/text/DefaultCaret.java 11 Oct 2005 18:31:15 -0000 @@ -274,6 +274,9 @@ public void mousePressed(MouseEvent event) { // FIXME: Implement this properly. + if (!(event.getButton() == MouseEvent.BUTTON1)) + return; + setDot(textComponent.viewToModel(event.getPoint())); } /** Index: javax/swing/text/PlainView.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v retrieving revision 1.18 diff -u -r1.18 PlainView.java --- javax/swing/text/PlainView.java 11 Oct 2005 16:18:34 -0000 1.18 +++ javax/swing/text/PlainView.java 11 Oct 2005 18:31:15 -0000 @@ -294,8 +294,32 @@ */ public int viewToModel(float x, float y, Shape a, Position.Bias[] b) { - // FIXME: not implemented - return 0; + Rectangle rec = a.getBounds(); + Document doc = getDocument(); + Element root = doc.getDefaultRootElement(); + + // PlainView doesn't support line-wrapping so we can find out which + // Element was clicked on just by the y-position + int lineClicked = (int) (y - rec.y) / metrics.getHeight(); + if (lineClicked >= root.getElementCount()) + return getEndOffset() - 1; + + Element line = root.getElement(lineClicked); + Segment s = new Segment(); + + int start = line.getStartOffset(); + int end = line.getEndOffset(); + try + { + doc.getText(start, end - start, s); + } + catch (BadLocationException ble) + { + //this should never happen + } + + int pos = Utilities.getTabbedTextOffset(s, metrics, rec.x, (int)x, this, start); + return Math.max (0, pos); } /**