-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
6, 7
-
generic
-
generic
Spec for javax.swing.text.changeHighlight(Object, int , int ) says:
"@exception BadLocationException for an invalid range specification"
Exception is not always throw when expected.
Platform: Windows, Solaris
JCK: runtime 7 b03
JDK: 6, 7
The following test fails:
api/javax_swing/text/Highlighter/index.html#Highlighter[Highlighter006]
Please see code extract from the test:
-----
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import java.awt.*;
public class H006 {
private static void runTest() {
JFrame jFrame = new JFrame();
JTextArea textArea = new JTextArea("Tested string");
jFrame.getContentPane().add(textArea);
jFrame.setVisible(true);
Highlighter highlighter = textArea.getHighlighter();
Highlighter.HighlightPainter myPainter = new Highlighter.HighlightPainter() {
public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {}
};
int negativeTestedData[][] = {{50, 0}, {-1, 1}, {-5, -4},
{Integer.MAX_VALUE, Integer.MIN_VALUE},
{Integer.MIN_VALUE, Integer.MAX_VALUE},
{Integer.MIN_VALUE, Integer.MIN_VALUE}};
String errorMessage4Negative = "";
for (int i = 0; i < negativeTestedData.length; i++) {
try {
Object objRef = highlighter.addHighlight(0, 1, myPainter);
highlighter.changeHighlight(objRef, negativeTestedData[i][0], negativeTestedData[i][1]);
} catch (BadLocationException e) {
continue;
}
errorMessage4Negative += "(" + negativeTestedData[i][0] + ", " + negativeTestedData[i][1] + ") ";
}
System.out.println("Method addHighlight() does not throw BadLocationException for \n" + errorMessage4Negative + ".");
jFrame.dispose();
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
runTest();
}
});
}
}
-----
"@exception BadLocationException for an invalid range specification"
Exception is not always throw when expected.
Platform: Windows, Solaris
JCK: runtime 7 b03
JDK: 6, 7
The following test fails:
api/javax_swing/text/Highlighter/index.html#Highlighter[Highlighter006]
Please see code extract from the test:
-----
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import java.awt.*;
public class H006 {
private static void runTest() {
JFrame jFrame = new JFrame();
JTextArea textArea = new JTextArea("Tested string");
jFrame.getContentPane().add(textArea);
jFrame.setVisible(true);
Highlighter highlighter = textArea.getHighlighter();
Highlighter.HighlightPainter myPainter = new Highlighter.HighlightPainter() {
public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {}
};
int negativeTestedData[][] = {{50, 0}, {-1, 1}, {-5, -4},
{Integer.MAX_VALUE, Integer.MIN_VALUE},
{Integer.MIN_VALUE, Integer.MAX_VALUE},
{Integer.MIN_VALUE, Integer.MIN_VALUE}};
String errorMessage4Negative = "";
for (int i = 0; i < negativeTestedData.length; i++) {
try {
Object objRef = highlighter.addHighlight(0, 1, myPainter);
highlighter.changeHighlight(objRef, negativeTestedData[i][0], negativeTestedData[i][1]);
} catch (BadLocationException e) {
continue;
}
errorMessage4Negative += "(" + negativeTestedData[i][0] + ", " + negativeTestedData[i][1] + ") ";
}
System.out.println("Method addHighlight() does not throw BadLocationException for \n" + errorMessage4Negative + ".");
jFrame.dispose();
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
runTest();
}
});
}
}
-----
- duplicates
-
JDK-6771184 Some methods in text package don't throw BadLocationException when expected
-
- Closed
-
- relates to
-
JDK-6770648 javax.swing.text.Highlighter.addHighlight() doesn't throw BadLocationException when expected
-
- Closed
-