File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes why am i getting a null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "why am i getting a null pointer exception" Watch "why am i getting a null pointer exception" New topic
Author

why am i getting a null pointer exception

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103

Hi guys budsy again , getting a problem in this code .I am taking two radio buttons and adding it to a buttongroup . Then i run System.out.println() to see the values but im getting a null pointer exception . I have used a similar code but in that i didn't get any error. Please help
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38802
    
  23
Apart from the fact that action commands are not object-oriented programming . . . don't know.
Put this series of print statements before that line where the error happens.

Then you find out which line is causing the problem. It is also worthwhile seeing what the getSelection method returns. Also which sort of Button that might apply to. And work out whether that is going to be null for anything here.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4387
    
    8

I suspect it's as simple as this: you haven't selected a button yet. So getSelection() is probably returning null.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why am i getting a null pointer exception