-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta2
-
x86
-
windows_nt
Name: krT82822 Date: 09/04/99
9/4/99 eval1127@eng -- still the case as of kestrel-beta, despite bug # 4198793 (which should be re-opened?)
-------------
The method 'int viewToModel(JTextComponent t, Point pt,
Position.Bias[] biasReturn)' always returns 'Forward' as the
Bias. The program below illustrates this problem. Just click on
characters advancing slowly. Wherever you click, Bias will be
'Forward'.
This bug is present in Jdk 1.2.1, 1.2.2, 1.3beta on
Windows NT 4.0 (with service pack 4 and 5).
Also note that the documentation for this function is
incorrect: it describes the parameters (x, y and a) of some
other method but not t, pt and biasReturn.
See http://java.sun.com/products/jdk/1.2/docs/api/javax/swing/plaf/TextUI.html#viewToModel(javax.swing.text.JTextComponent, java.awt.Point, javax.swing.text.Position.Bias[])
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
public class TextAreaTest extends JTextArea
{
TextAreaTest()
{
setText ("some text in a text area\nsecond line");
Font f = getFont();
setFont(new Font(f.getName(), f.getStyle(), 24));
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e)
{
Point pt=new Point(e.getX(), e.getY());
Position.Bias[] biasRet=new Position.Bias[1];
int index=getUI().viewToModel(TextAreaTest.this, pt, biasRet);
System.out.println("x="+e.getX()+": index="+index+", Bias="+ biasRet[0]);
}
});
}
public static void main(String args[])
{
JFrame frame = new JFrame("TextArea Bias test");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
JOptionPane.setRootFrame(frame);
frame.getContentPane().add(new TextAreaTest());
frame.pack();
frame.setSize(new Dimension(300,150));
frame.show();
}
}
(Review ID: 94812)
======================================================================