Hi,
I get this error:
Exception in thread "Thread-4" java.lang.NullPointerException

When I try to send the vector to my form.
Does someone knows where I made a mistake?

Here is a part of my code:
(this part is from my clientapplication (where I make a connection with the server)

if (msg.equals("Schools")) {
schools= (Vector<school>) istream.readObject();
System.out.println("amount of schools: " + schools.size());
System.out.println(schools);
till here everything worked fine. when I print the vector schools I get all the items in this vector.


frmschool.showSchools(schools);

Here I got the nullpointer exception.
here the part where I want to place the schools in a textbox:
(frmschool):

public void showUsers(Vector<School> schools) {
txtOnline.setText("");
for (School s : schools) {
txtOnline.append(s.toString() + "\n");
//        }


}

-----------------------------------------------------------------
Thanks in advance!

Edited 3 Years Ago by happygeek: fixed formatting

I think txtOnline should be null..... print txtOnline just inside the showSchools method

Edited 3 Years Ago by happygeek: fixed formatting

it's showschools, (sorry I copied the wrong method, but the inside is the same)

it's showschools, (sorry I copied the wrong method, but the inside is the same)

txtOnline should be null just inside ur method... so any operation on txtOnline will throw null pointer

txtOnline should be null just inside ur method... so any operation on txtOnline will throw null pointer

Thanks, but how do I do this?

When I have this method:

public void showSchools(Vector<Object> schools) {
         txtOnline.setText("");
        for (Object s : schools) {
            txtOnline.append(s.toString() + "\n");
            System.out.println(schools.toString());  --> here I get the values of the vector, but still not in my txtOnline. 
        }
        System.out.println(schools.toString());
    }
This article has been dead for over six months. Start a new discussion instead.