Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-05-2007, 05:02 PM
Member
 
Join Date: Jul 2007
Posts: 40
barney is on a distinguished road
ERROR: nullPointerException in applet
Hi, I have this applet that starts as soon as the page is loaded. But i wanted it so you have to click the applet before it starts(getting keyboard focus) or else its just a race to click the applet before you die... so i tried the following:
Code:
public class Whatever implements Runnable,KeyListener,MouseListener{ ... Graphics begin; Thread th; ... public void init(){ ... begin.drawString("click to start",100,50); addMouseListener(this); } ... public void mousePressed(MouseEvent e){ begin.dispose(); th.start(); }
And i got a NullPointerException... whatever that is. So everything else works fine.
Could anyone tell me a better way to go about this or a way to fix it?
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 08:11 AM
Member
 
Join Date: Jul 2007
Posts: 40
lenny is on a distinguished road
NullPointerException means that you're trying to use an object that is null, i.e., you haven't "new"-ed it.
You're not showing all of the code, and you didn't say when exactly you're getting the exception (immediately, or when you click the applet with the mouse?). Are you sure you created th, because I don't see that in the code, and if you didn't then th.start() would throw an NullPointerException because that is null.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
NullPointerException ravian New To Java 2 12-07-2007 05:20 PM
NullPointerException Feng New To Java 5 11-24-2007 08:51 PM
ERROR: nullPointerException mathias New To Java 1 08-05-2007 07:54 AM
applet error Peter Advanced Java 2 07-04-2007 08:04 AM
Error Java.lang.NullPointerException in JBuilder2006 Jack Other IDEs 2 07-02-2007 03:29 AM


All times are GMT +3. The time now is 04:16 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org