[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:
   at java.util.Hashtable.put (Hashtable.java:437)
   at javax.swing.text.SimpleAttributeSet.addAttribute
   at javax.swing.text.StyleContext.addAttribute (StyleContext.java:551)
   at javax.swing.text.AbstractDocument$AbstractElement.setResolveParent
   at javax.swing.text.DefaultStyledDocument.setLogicalStyle
   at javax.swing.text.DefaultStyledDocument.<init>
   at javax.swing.text.DefaultStyledDocument.<init>
   at testcase.<init> (testcase.java:8)
   at testcase.main (testcase.java:5)

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

------- 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. 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]