| Author |
Run Time error
|
Aroma Karim
Greenhorn
Joined: Nov 01, 2012
Posts: 24
|
|
[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
|
|
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: 10040
|
|
|
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.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Ivan Franko
Ranch Hand
Joined: May 30, 2011
Posts: 44
|
|
Take a look at line 29:
Variable resultt - what is this?
|
 |
Aroma Karim
Greenhorn
Joined: Nov 01, 2012
Posts: 24
|
|
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: 16811
|
|
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
|
|
|