0

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 by happygeek: fixed formatting

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Alianncox
0

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

Edited by happygeek: fixed formatting

0

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

0

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

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.