File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Changing color for button in arrary Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Changing color for button in arrary" Watch "Changing color for button in arrary" New topic
Author

Changing color for button in arrary

B. Bent
Greenhorn

Joined: Jun 05, 2009
Posts: 5
Hi to everybody. New to java and have a problem.
I construct an array of buttons and now I want to change background color of button when I click,
but I got null pointer exception. Can somebody help me with that.


Thanks
W Pearce
Ranch Hand

Joined: Jan 06, 2009
Posts: 32
I think it's because you're re-decarling your instance variable array for your buttons in your constructor. Try changing
to


SCJP 6, SCWCD 5
B. Bent
Greenhorn

Joined: Jun 05, 2009
Posts: 5
It works.
And I search through internet couple days, and couldn't find solutions.

THANKS MAN !
Matthew Cox
Greenhorn

Joined: May 25, 2009
Posts: 29
B. Bent wrote:It works.
And I search through internet couple days, and couldn't find solutions.

THANKS MAN !


Yay!

Now, you should be wanting to understand WHY that fixed it.

Read up on "Scope of Variables"

This topic should help you understand why such a small change from


to



fixed your problem.
B. Bent
Greenhorn

Joined: Jun 05, 2009
Posts: 5
Need to take second look on that obviously. I was confused because this was array.
Still learning basic things...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing color for button in arrary