-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
None
-
1.2.2
-
x86
-
windows_nt
The following test case illustrates the bug. If no exception is thrown, it worked:
/*
* @test %I% %E%
* @bug
* @summary Makes sure CompositeView passes modelToView to the correct
* components when invoked with a backward bias.
* @author Scott Violet
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class ModelToViewTest implements Runnable {
public static void main(String[] args) throws Throwable {
new ModelToViewTest();
}
boolean done;
JTextPane textPane;
Throwable error;
public ModelToViewTest() throws Throwable {
textPane = new JTextPane();
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setBold(sas, true);
try {
textPane.getDocument().insertString(0, "foo", sas);
} catch (BadLocationException ble) {
System.out.println("BLE: " + ble);
}
JFrame frame = new JFrame();
frame.getContentPane().add(textPane);
frame.pack();
frame.show();
SwingUtilities.invokeLater(this);
synchronized(this) {
while (!done) {
wait();
}
}
if (error != null) {
throw error;
}
}
public void run() {
Dimension pref = textPane.getPreferredSize();
try {
View root = textPane.getUI().getRootView(textPane);
Rectangle rect = root.modelToView(0, Position.Bias.Forward,
3, Position.Bias.Backward,
textPane.getBounds()).
getBounds();
System.out.println("RECT: " + rect);
for (int x = rect.x + 10; x >= rect.x; x--) {
System.out.println(x + ": " + textPane.viewToModel
(new Point(x, rect.y)));
}
} catch (BadLocationException ble) {
error = ble;
} catch (IllegalArgumentException iae) {
error = iae;
}
synchronized(this) {
done = true;
notify();
}
}
}
/*
* @test %I% %E%
* @bug
* @summary Makes sure CompositeView passes modelToView to the correct
* components when invoked with a backward bias.
* @author Scott Violet
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class ModelToViewTest implements Runnable {
public static void main(String[] args) throws Throwable {
new ModelToViewTest();
}
boolean done;
JTextPane textPane;
Throwable error;
public ModelToViewTest() throws Throwable {
textPane = new JTextPane();
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setBold(sas, true);
try {
textPane.getDocument().insertString(0, "foo", sas);
} catch (BadLocationException ble) {
System.out.println("BLE: " + ble);
}
JFrame frame = new JFrame();
frame.getContentPane().add(textPane);
frame.pack();
frame.show();
SwingUtilities.invokeLater(this);
synchronized(this) {
while (!done) {
wait();
}
}
if (error != null) {
throw error;
}
}
public void run() {
Dimension pref = textPane.getPreferredSize();
try {
View root = textPane.getUI().getRootView(textPane);
Rectangle rect = root.modelToView(0, Position.Bias.Forward,
3, Position.Bias.Backward,
textPane.getBounds()).
getBounds();
System.out.println("RECT: " + rect);
for (int x = rect.x + 10; x >= rect.x; x--) {
System.out.println(x + ": " + textPane.viewToModel
(new Point(x, rect.y)));
}
} catch (BadLocationException ble) {
error = ble;
} catch (IllegalArgumentException iae) {
error = iae;
}
synchronized(this) {
done = true;
notify();
}
}
}