views:

204

answers:

3

when i run my application i get the following error:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:546)
    at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:460)
    at javax.swing.text.FlowView.layout(FlowView.java:184)
    at javax.swing.text.BoxView.setSize(BoxView.java:380)
    at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
    at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
    at javax.swing.text.BoxView.layout(BoxView.java:691)
    at javax.swing.text.BoxView.setSize(BoxView.java:380)
    at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1702)
    at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1034)
    at javax.swing.text.DefaultCaret.repaintNewCaret(DefaultCaret.java:1291)
    at javax.swing.text.DefaultCaret$1.run(DefaultCaret.java:1270)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

as the error does not mention any of my classes, how would i go about in finding what is causing this?

if i try: public void notifyChatMessage(String message){...} the error goes away (NOT).

edit: upon further testing it turns out the above generates the error also.

but if i try: public void notifyChatMessage(Object message){...} the error is reported.

please advise.

EDIT:

        public void notifyChatMessage(String message){


         AppMessage appMessage = new AppMessage(AppMessage.Target.Chat, message);
         setChanged();
         notifyObservers(appMessage);

     }

AppMessage:

public class AppMessage implements Serializable {

/**
 * Message header for target: game, chat
 */
public enum Target {
    Game, Chat
}

/**
 * Holds target
 */
public Target target;

/**
 * Holds state message
 */
public Object message;

/**
 * Construct using parameter data
 * @param target
 * @param message
 */
public AppMessage(Target target, Object message){

    this.target = target;
    this.message = message;

}

}

EDIT: even with the error report the program continues to run and i cannot see any lack of performance ie. error in running which is making the task of localizing the problem more complex.

EDIT: when i run it through the debugger in netbeans i get: Debugger stopped on uncompilable source code.

EDIT: the exception is being thrown because of cross thread GUI updates. investigating invokeLater and invokeAndWait for solution.

SOLUTION: invokeAndWait

A: 

Use the source... start with javax.swing.text.FlowView line 546

David Soroko
i tried that but thats Java lib code and i dont know that it is saying exactly.
iEisenhower
Convenience link: http://www.docjar.com/html/api/javax/swing/text/FlowView.java.html
Lord Torgamus
@Lord Torgamus nice one but probably the wrong version as the last line in that source file is 412. The correct java file will be in `src.zip`
David Soroko
@David, you may be right. I almost didn't post the link for that very reason, but I thought it was due to docjar automation snipping out the static classes, changing the line numbers but not the code. Either way though, using `src.zip` will be ironclad.
Lord Torgamus
A: 

The call javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:546) is trying to process something that is NULL. Looking at its signature. layoutRow(FlowView fv, int rowIndex, int pos) the only thing that can be NULL is FlowView fv since the int primatives can't be NULL. So without having the code to run and step debug thru, I would say that somewhere something is either not setting FlowView or setting it to NULL.

fuzzy lollipop
A: 

SOLUTION: invokeAndWait

iEisenhower