-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b15
-
x86
-
windows_xp
-
Verified
FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Users cannot see what lines were selected if the lines consist of line separators('\n') only.
The behaviour was changed by fixing another bug (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4855860). Width for a child view '\n' is set to 0 therefore the selection is not visible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run. You don't see anything selected on 1.5.0_05. Users could be
confused from this behaviour. Line separators should have non zero width
while selecting text(for empty lines).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selection painter should handle this.
ACTUAL -
Selection for empty these lines is not visible.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
/**
* Bug Preview for empty selection - selection of empty lines
*/
public class BugPreview {
final static String endOfLineProperty =
System.getProperty("line.separator", "\n");
private static void addEmptyLine(JTextComponent c) throws
BadLocationException {
final Document document = c.getDocument();
document.insertString(document.getLength(), endOfLineProperty,
null);
}
public static void main(String[] args) {
JTextComponent editor = new JTextPane();
try {
addEmptyLine(editor);//a few empty lines
addEmptyLine(editor);
addEmptyLine(editor);
} catch (BadLocationException e) {
e.printStackTrace();
}
editor.selectAll(); // now we select all text, but empty lines are not marked as selected on 1.5.0_05
JFrame frame = new JFrame();
frame.setTitle("Demo");
frame.setSize(200, 150);
frame.getContentPane().add(editor);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.2_09
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Users cannot see what lines were selected if the lines consist of line separators('\n') only.
The behaviour was changed by fixing another bug (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4855860). Width for a child view '\n' is set to 0 therefore the selection is not visible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run. You don't see anything selected on 1.5.0_05. Users could be
confused from this behaviour. Line separators should have non zero width
while selecting text(for empty lines).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selection painter should handle this.
ACTUAL -
Selection for empty these lines is not visible.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
/**
* Bug Preview for empty selection - selection of empty lines
*/
public class BugPreview {
final static String endOfLineProperty =
System.getProperty("line.separator", "\n");
private static void addEmptyLine(JTextComponent c) throws
BadLocationException {
final Document document = c.getDocument();
document.insertString(document.getLength(), endOfLineProperty,
null);
}
public static void main(String[] args) {
JTextComponent editor = new JTextPane();
try {
addEmptyLine(editor);//a few empty lines
addEmptyLine(editor);
addEmptyLine(editor);
} catch (BadLocationException e) {
e.printStackTrace();
}
editor.selectAll(); // now we select all text, but empty lines are not marked as selected on 1.5.0_05
JFrame frame = new JFrame();
frame.setTitle("Demo");
frame.setSize(200, 150);
frame.getContentPane().add(editor);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.2_09
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
- relates to
-
JDK-4855860 JTextPane returns too large preferredSize in some specific cases
- Resolved
-
JDK-6427770 JLabel with HTML no longer displays non-spacing characters under 1.5.0_06
- Closed