CertainLach / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
0 stars 0 forks source link

NullPointerException when setting another EditorKit in the application #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
2010-06-09 15:09:09,754|EntryCController|ERROR|*C<1>[0ARvd ENTRY CD:null]:  
perform CInstr_Generic raised:
java.lang.NullPointerException
        at jsyntaxpane.components.LineNumbersRuler.install(LineNumbersRuler.java:135)
        at jsyntaxpane.DefaultSyntaxKit.installComponent(DefaultSyntaxKit.java:143)
        at jsyntaxpane.DefaultSyntaxKit.addComponents(DefaultSyntaxKit.java:127)
        at jsyntaxpane.DefaultSyntaxKit.install(DefaultSyntaxKit.java:338)
        at javax.swing.JEditorPane.setEditorKit(JEditorPane.java:1097)
        at javax.swing.JEditorPane.setContentType(JEditorPane.java:1021)
        at de.znt.opint.oic.views.basic.HTMLStringViewImpl.<init>(HTMLStringViewImpl.java:135)
        at de.znt.opint.oic.factories.ViewFactory.create(ViewFactory.java:164)
        at de.znt.opint.oic.controller.CController.createView(CController.java:990)
        at de.znt.opint.oic.controller.CController.insertView(CController.java:572)
        at de.znt.opint.oic.controller.MultipleCController.insertView(MultipleCController.java:86)
        at de.znt.opint.oic.controller.CController.addDependent(CController.java:519)
        at de.znt.opint.oic.controller.CController.vinstruct(CController.java:1329)
        at de.znt.opint.oic.controller.CController.processJobv(CController.java:403)
        at de.znt.opint.oic.controller.CController.receiveInstruction(CController.java:456)
        at de.znt.opint.oic.Receiver.processJobv(Receiver.java:65)
        at de.znt.opint.util.jobqueue.Job.process(Job.java:33)
        at de.znt.opint.util.jobqueue.JobQueue.processNextJob(JobQueue.java:365)
        at de.znt.opint.util.jobqueue.JobQueue.access$2(JobQueue.java:354)
        at de.znt.opint.util.jobqueue.JobQueue$WorkerThread.run(JobQueue.java:426)

in LineNumbersRuler in the method install() , it should be checked if (sp!= 
null)

  @Override
        public void install(final JEditorPane editor) {
                this.editor = editor;

                setFont(editor.getFont());

                // setMinimumDisplayDigits(3);

                editor.getDocument().addDocumentListener(this);
                editor.addCaretListener(this);
                editor.addPropertyChangeListener(this);
                JScrollPane sp = getScrollPane(editor);
                if(sp != null)
                {
                    sp.setRowHeaderView(this);
                    mouseListener = new MouseAdapter() {

                            @Override
                            public void mouseClicked(MouseEvent e) {
                                    GotoLineDialog.showForEditor(editor);
                            }
                    };
                }    
                addMouseListener(mouseListener);
                status = Status.INSTALLING;
        }

Original issue reported on code.google.com by liviu.ca...@gmail.com on 9 Jun 2010 at 1:11

GoogleCodeExporter commented 9 years ago
To be able to put line numbers, the editor MUST be enclosed in a ScrollPane.  
Bypassing the null pointer check will have other side effects later.
This is reported before, and sorry to say the answer is:
1) Must have the editor in scrollpane, or
2) remove line numbers.

Original comment by ayman.al...@gmail.com on 22 Jun 2010 at 8:01