Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AWT-EventQueue-0" - need Help  RSS feed

 
Beth Laguardia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Swing and I wonder if somebody can explain to me what is wrong with the program I am making:

Here's the code:



Here's the error:


Please explain to me what's wrong.. ANybody? Thank you..
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your firstGui.SimpleGui_2 code looks ok to me,
though I haven't actually tried running it.

The error complains about the actionPerformed()
method in the firstGui.SimpleLayout class, which
you haven't shown us.
 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you managed to pass null to anything? This two-year old thread resurfaced yesterday; I wrote about how I look for NullPointerExceptions, which are a frequent problem, so you need to know about them.
 
Beth Laguardia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian: Yeah, sorry. The first program that I posted is a working program.

Here's the not working program.. sorry for the inconvenience..



Please somebody explain what's wrong? Thank you all..

[ August 28, 2008: Message edited by: Beth Laguardia ]
[ August 28, 2008: Message edited by: Beth Laguardia ]
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SimpleLayout.actionPerformed(SimpleLayout.java:40)

The error message says an object reference (pointer) at source line 40 in SimpleLayout is null. Look at that line of code and see what pointer could be null. I bet its button1.

In the go method you've "hidden" the definition of button1 with a local one and have NOT initialized the global one referenced where the NPE occurs.
[ August 28, 2008: Message edited by: Norm Radder ]
 
Beth Laguardia
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your right!

I change this

to ths:

Thank you!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!