-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6
-
Cause Known
-
generic
-
generic
- Compile and run the following test case.
- Move the mouse over the JEditorPane and it will print out the result of viewToModel for the point under the mouse.
- Notice that the bias it returns for locations in the top inset is null.
This is an unexpected return value for the bias. It caused problems with DnD code that didn't expect null. It's been worked around (see 6456844) in the DnD code for now, but should be fixed.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
public class V2MTest extends JFrame {
public V2MTest() {
super("V2MTest");
final JEditorPane ep = new JEditorPane();
ep.setContentType("text/html");
ep.setText("a\nb\nc");
ep.setBorder(new EmptyBorder(20, 20, 20, 20));
getContentPane().add(ep);
ep.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent me) {
Position.Bias[] bias = new Position.Bias[1];
int index = ep.getUI().viewToModel(ep, me.getPoint(), bias);
System.out.println(index + ", " + bias[0]);
}
});
}
private static void createAndShowGUI(String[] args) {
V2MTest test = new V2MTest();
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test.setSize(400, 400);
test.setLocationRelativeTo(null);
test.setVisible(true);
}
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI(args);
}
});
}
}
- Move the mouse over the JEditorPane and it will print out the result of viewToModel for the point under the mouse.
- Notice that the bias it returns for locations in the top inset is null.
This is an unexpected return value for the bias. It caused problems with DnD code that didn't expect null. It's been worked around (see 6456844) in the DnD code for now, but should be fixed.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
public class V2MTest extends JFrame {
public V2MTest() {
super("V2MTest");
final JEditorPane ep = new JEditorPane();
ep.setContentType("text/html");
ep.setText("a\nb\nc");
ep.setBorder(new EmptyBorder(20, 20, 20, 20));
getContentPane().add(ep);
ep.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent me) {
Position.Bias[] bias = new Position.Bias[1];
int index = ep.getUI().viewToModel(ep, me.getPoint(), bias);
System.out.println(index + ", " + bias[0]);
}
});
}
private static void createAndShowGUI(String[] args) {
V2MTest test = new V2MTest();
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test.setSize(400, 400);
test.setLocationRelativeTo(null);
test.setVisible(true);
}
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI(args);
}
});
}
}
- relates to
-
JDK-6456844 NPE when drag into JEditorPane with HTML content
-
- Resolved
-