Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Button click - String operation" Watch "Button click - String operation" New topic

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?

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(
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 Source)
[ March 20, 2006: Message edited by: Brandi Love ]
Joe Ess

Joined: Oct 29, 2001
Posts: 8836

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!
I agree. Here's the link:
subject: Button click - String operation
Similar Threads
Componet Allignment
Not writing to new file...
file renaming...
fields not formatted correctly
text box - GridBagLayout