Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes Button click - String operation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Button click - String operation" Watch "Button click - String operation" New topic
Author

Button click - String operation

Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
I have a window in which the user enters their information, which is then recorded to a file. Everything works except for the string comparison (.equals(), in bold); it didn't start to give this error (also shown below) until I added that line and another piece of code I wrote is having the same problem. I can't figure out what the problem here is. It compiles but when I click the register button it gives this crazy error. Does anyone have any ideas?

*update*
I'm now catching the NullPointerException so I don't get the huge error, but now all it does is catch the exception, still can't figure out why the string comparison is causing this.




Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at RegisterNewMember$RegButtonListener.actionPerformed(RegisterNewMember.java:115)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
[ March 20, 2006: Message edited by: Brandi Love ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

You know inLine can be null. You are checking for that condition in your while loop. Why aren't you checking if it is null before you attempt to use it?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
Genius! Can't believe I missed that, I checked for null also and the problem seems to be solved. Thanks so much!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Button click - String operation