I have a 3x3 array of MSTextField which is a class I created which extends JTextField . I'm trying to set all of the text fields to display the empty string ( "" ). My problem is I'm getting a nullPointerException at the end of the method which is supposed to do this. I think the problem might be that I haven't initialized the array yet (earlier I thought that I was doing this by setting each text field to "" but I think I was wrong). How do I initialize an array of MSTextField so that I can set the text? Also, once they're initialized will textFieldArray[row][column].setText( "" ); at the end of my for loops work?
SMITA6076 0 Light Poster
Recommended Answers
Jump to Post— NormR1 580When using arrays of objects, there are two steps.
One: create the array object. (Yes arrays are very like objects)
Two: fill the array with the objectsYou probably have not done step two.
textFieldArray[j] = new TextField(); // set i,j element to a TextField
All 2 Replies
Reply to this topic Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.