[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/23017] swing: DefaultStyledDocument(new StyleContext()) t
From: |
gcc-bugzilla at gcc dot gnu dot org |
Subject: |
[Bug classpath/23017] swing: DefaultStyledDocument(new StyleContext()) throws NullPointerException |
Date: |
8 Sep 2010 18:04:50 -0000 |
Steps to reproduce:
1. Compile and run the attached testcase.
Expected results:
1. An empty window shows up.
Actual results:
1. No window is shown and the following exception is thrown:
java.lang.NullPointerException
at java.util.Hashtable.put (Hashtable.java:437)
at javax.swing.text.SimpleAttributeSet.addAttribute
(SimpleAttributeSet.java:66)
at javax.swing.text.StyleContext.addAttribute (StyleContext.java:551)
at javax.swing.text.AbstractDocument$AbstractElement.setResolveParent
(AbstractDocument.java:531)
at javax.swing.text.DefaultStyledDocument.setLogicalStyle
(DefaultStyledDocument.java:188)
at javax.swing.text.DefaultStyledDocument.<init>
(DefaultStyledDocument.java:86)
at javax.swing.text.DefaultStyledDocument.<init>
(DefaultStyledDocument.java:78)
at testcase.<init> (testcase.java:8)
at testcase.main (testcase.java:5)
Testcase:
import javax.swing.*;
import javax.swing.text.*;
public class testcase extends JFrame {
public static void main(String[] args) {
(new testcase()).show();
}
public testcase() {
new DefaultStyledDocument(new StyleContext());
}
}
This testcase is reduced from omegaT available at
http://sourceforge.net/projects/omegat/
------- Comment #1 from from-classpath at savannah dot gnu dot org 2005-07-05
13:59 -------
The reason of throwing that exception is that DefaultStyledDocument constructor
tries to set the default style of the newly created StyledContext as its
logical style. To get that style, it calls
StyledContext.getStyle(StyleContext.DEFAULT_STYLE) and receives
null in return. The attempt to add that null to the table raises an exception.
After the path below the provided test case does not longer throw an exception
and the empty frame appears.
2005-07-05 Audrius Meskauskas <address@hidden>
* javax/swing/text/StyleContext.java
(defaultStyle): New field.
(constructor): Add defaultStyle to the styleTable.
(DEFAULT_STYLE, getStyle, getStyleNames): Documented.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23017
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/23017] swing: DefaultStyledDocument(new StyleContext()) throws NullPointerException,
gcc-bugzilla at gcc dot gnu dot org <=