Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList null pointer exception

 
Scott A Burch
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get a button to open a file directory, retrieve some file names and add them as elements to a JLIst. The code opens the filechooser flawlessly, but the minute I click OK in the save dialog, I get a null pointer exception.




The problem comes with the button listener. I get null pointer exception at:



Please help me sort this out. Thanks!
 
Scott A Burch
Ranch Hand
Posts: 58
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Figured it out. I had created a local variable listModel and was hiding the list field.

I changed the line



to



and it works. And the delete button works now too. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic