-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6u1
-
Cause Known
-
sparc
-
solaris_10
I made the following changes to jdk1.6.0/demo/jfc/Stylepad/src/Stylepad.java :
--- jdk1.6.0/demo/jfc/Stylepad/src/Stylepad.java Fri Jun 2 02:44:52 2006
+++ Stylepad.java Mon Aug 14 09:50:30 2006
@@ -131,7 +131,11 @@
StyleContext sc = new StyleContext();
DefaultStyledDocument doc = new DefaultStyledDocument(sc);
initDocument(doc, sc);
- JTextPane p = new JTextPane(doc);
+
+ //JTextPane p = new JTextPane(doc);
+ JTextPane p = new JTextPane();
+ p.setEditorKit(new AsyncStyledEditorKit());
+ p.setStyledDocument(doc);
p.setDragEnabled(true);
//p.getCaret().setBlinkRate(0);
@@ -320,4 +324,22 @@
public int getIconHeight() { return 12; }
}
+
+ private class AsyncStyledEditorKit extends StyledEditorKit
+ implements ViewFactory {
+
+ private final ViewFactory superViewFactory = super.getViewFactory();
+
+ public ViewFactory getViewFactory() {
+ return this;
+ }
+
+ public View create(Element elem) {
+ if (AbstractDocument.SectionElementName.equals(elem.getName())) {
+ return new AsyncBoxView(elem, View.Y_AXIS);
+ }
+ return superViewFactory.create(elem);
+ }
+ }
+
}
The result is:
$ java Stylepad
Exception in thread "main" java.lang.NullPointerException
at javax.swing.text.AsyncBoxView.preferenceChanged(AsyncBoxView.java:493)
at javax.swing.text.View.preferenceChanged(View.java:302)
at javax.swing.text.BoxView.preferenceChanged(BoxView.java:269)
at javax.swing.text.FlowView$FlowStrategy.insertUpdate(FlowView.java:356)
at javax.swing.text.FlowView.loadChildren(FlowView.java:126)
at javax.swing.text.CompositeView.setParent(CompositeView.java:122)
at javax.swing.text.FlowView.setParent(FlowView.java:272)
at javax.swing.text.AsyncBoxView$ChildState.<init>(AsyncBoxView.java:1185)
at javax.swing.text.AsyncBoxView.createChildState(AsyncBoxView.java:202) at javax.swing.text.AsyncBoxView.replace(AsyncBoxView.java:356)
at javax.swing.text.AsyncBoxView.loadChildren(AsyncBoxView.java:393)
at javax.swing.text.AsyncBoxView.setParent(AsyncBoxView.java:461)
at javax.swing.plaf.basic.BasicTextUI$RootView.setView(BasicTextUI.java:1273)
at javax.swing.plaf.basic.BasicTextUI.setView(BasicTextUI.java:639)
at javax.swing.plaf.basic.BasicTextUI.modelChanged(BasicTextUI.java:628) at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.propertyChange(BasicTextUI.java:1731)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
at java.awt.Component.firePropertyChange(Component.java:7802)
at javax.swing.text.JTextComponent.setDocument(JTextComponent.java:437)
at javax.swing.JTextPane.setDocument(JTextPane.java:114)
at javax.swing.JEditorPane.setEditorKit(JEditorPane.java:981)
at javax.swing.JTextPane.setEditorKit(JTextPane.java:476)
at Stylepad.createEditor(Stylepad.java:137)
at Notepad.<init>(Notepad.java:100)
at Stylepad.<init>(Stylepad.java:72)
at Stylepad.main(Stylepad.java:85)
--- jdk1.6.0/demo/jfc/Stylepad/src/Stylepad.java Fri Jun 2 02:44:52 2006
+++ Stylepad.java Mon Aug 14 09:50:30 2006
@@ -131,7 +131,11 @@
StyleContext sc = new StyleContext();
DefaultStyledDocument doc = new DefaultStyledDocument(sc);
initDocument(doc, sc);
- JTextPane p = new JTextPane(doc);
+
+ //JTextPane p = new JTextPane(doc);
+ JTextPane p = new JTextPane();
+ p.setEditorKit(new AsyncStyledEditorKit());
+ p.setStyledDocument(doc);
p.setDragEnabled(true);
//p.getCaret().setBlinkRate(0);
@@ -320,4 +324,22 @@
public int getIconHeight() { return 12; }
}
+
+ private class AsyncStyledEditorKit extends StyledEditorKit
+ implements ViewFactory {
+
+ private final ViewFactory superViewFactory = super.getViewFactory();
+
+ public ViewFactory getViewFactory() {
+ return this;
+ }
+
+ public View create(Element elem) {
+ if (AbstractDocument.SectionElementName.equals(elem.getName())) {
+ return new AsyncBoxView(elem, View.Y_AXIS);
+ }
+ return superViewFactory.create(elem);
+ }
+ }
+
}
The result is:
$ java Stylepad
Exception in thread "main" java.lang.NullPointerException
at javax.swing.text.AsyncBoxView.preferenceChanged(AsyncBoxView.java:493)
at javax.swing.text.View.preferenceChanged(View.java:302)
at javax.swing.text.BoxView.preferenceChanged(BoxView.java:269)
at javax.swing.text.FlowView$FlowStrategy.insertUpdate(FlowView.java:356)
at javax.swing.text.FlowView.loadChildren(FlowView.java:126)
at javax.swing.text.CompositeView.setParent(CompositeView.java:122)
at javax.swing.text.FlowView.setParent(FlowView.java:272)
at javax.swing.text.AsyncBoxView$ChildState.<init>(AsyncBoxView.java:1185)
at javax.swing.text.AsyncBoxView.createChildState(AsyncBoxView.java:202) at javax.swing.text.AsyncBoxView.replace(AsyncBoxView.java:356)
at javax.swing.text.AsyncBoxView.loadChildren(AsyncBoxView.java:393)
at javax.swing.text.AsyncBoxView.setParent(AsyncBoxView.java:461)
at javax.swing.plaf.basic.BasicTextUI$RootView.setView(BasicTextUI.java:1273)
at javax.swing.plaf.basic.BasicTextUI.setView(BasicTextUI.java:639)
at javax.swing.plaf.basic.BasicTextUI.modelChanged(BasicTextUI.java:628) at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.propertyChange(BasicTextUI.java:1731)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
at java.awt.Component.firePropertyChange(Component.java:7802)
at javax.swing.text.JTextComponent.setDocument(JTextComponent.java:437)
at javax.swing.JTextPane.setDocument(JTextPane.java:114)
at javax.swing.JEditorPane.setEditorKit(JEditorPane.java:981)
at javax.swing.JTextPane.setEditorKit(JTextPane.java:476)
at Stylepad.createEditor(Stylepad.java:137)
at Notepad.<init>(Notepad.java:100)
at Stylepad.<init>(Stylepad.java:72)
at Stylepad.main(Stylepad.java:85)
- relates to
-
JDK-6740328 ZoneView and AsyncBoxView cause NullPointerException
-
- Open
-