aspose file tools*
The moose likes Beginning Java and the fly likes Run Time error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Run Time error" Watch "Run Time error" New topic
Author

Run Time error

Abeer El-shaer
Greenhorn

Joined: Nov 01, 2012
Posts: 29
[color=darkred] [/color]



the ERROR IS IN RUN TIME

Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1039)
at java.awt.Container.add(Container.java:363)
at Adition1.<init>(Adition1.java:29)
at Adition1.main(Adition1.java:43)
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

A couple of suggestsions:

1. Don't use a lot of color. It makes your post hard to read. You tried to make the whole thing dark red. Fortunately, you didn't use the tags right, so it didn't work.

2. Put only one statement on a line. This is bad:


3. Don't name variables the same as methods. Calling add(add) is confusing. Variable names should be nouns (things) or at least noun-ish. Method names should be verbs (actions).

If the line 29 it's complaining about matches the line 29 in the code you posted, then it's the one I mentioned in my point #2 above. Since the error is occurring inside Container.add(), and not on line 29 directly, we know that c is not null. So either resultt (also a confusing name) must be null or the "add" variable must be null. Possibly both.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11305
    
  16

You will also find that you get much more help here if you actually ask a question. Simply posting 45 lines of code and an error you got turns a lot of folks off. It looks like you don't feel it important enough to spend the time to formulate a real question, so many folks will not find it important enough to compose a reply.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ivan Franko
Ranch Hand

Joined: May 30, 2011
Posts: 44
Take a look at line 29:


Variable resultt - what is this?
Abeer El-shaer
Greenhorn

Joined: Nov 01, 2012
Posts: 29
Ivan Franko wrote:Take a look at line 29:


Variable resultt - what is this?

it's a JTextField variable!!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18825
    
  40

Aroma Karim wrote:
Ivan Franko wrote:Take a look at line 29:


Variable resultt - what is this?

it's a JTextField variable!!



And is the JTextField variable actually pointing to a JTextField object??


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: Run Time error