Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


[java] Newbie is stuck! Help!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Zook   Members   -  Reputation: 134

Like
Likes
Like

Posted 28 September 2000 - 10:08 PM

How can I make an array of Buttons, or any other objects?
I have this line
Button [][] b=new Button[size][size];
and at run-time I get the error NullPointerException when I try to access the member functions.
What`s wrong?

Sponsor:

#2 ARCHIGAMER   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 September 2000 - 10:45 PM

you have not defined the objects that you created they all have no value (null) which is illegal in java.

I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work

#3 bobbin   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 September 2000 - 10:47 PM


When you define an array you build the array object (not strictly true, but anyway) but don''t initialize the elements (the object inside the array). You need to construct the elements before you can reference them (ie b[x][y] = new button())..

#4 Hodglim   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 September 2000 - 04:45 AM

This might help ...


Button [][] b = new Button[size][size];
for(int x = 0; x < size; x++)
for(int y = 0; y < size; y++)
b[x][y] = new Button();




Edited by - Hodglim on September 29, 2000 11:47:08 AM

#5 Zook   Members   -  Reputation: 134

Like
Likes
Like

Posted 29 September 2000 - 07:27 AM

Yeah, it works!!
Thanks for the help guys!





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS