Tuesday, 27 August 2013

Create new user jFrame and add to main

Create new user jFrame and add to main

I have written jFrame window (newUserPanel), that collects informations
about new user. After accepting data it adds new User to ArrayList, that
collects all users. Problem is I'd like it to also save (via serilization)
my updated ArrayList to file.
(ALL THIS IS UNDER ONE jButton!)
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
newUserPanel tempPanel= new newUserPanel ();
dodana.setVisible(true);
User tempUser= new User();
tempUser= dodana.getUser();
listOfUsers.add(tempUser);
}});
try {
ObjectOutputStream out = new ObjectOutputStream(new
FileOutputStream("usersList.obiekt"));
out.writeObject(listOfUsers);
out.close();
} catch (IOException i) {
i.printStackTrace();
}
I assume it is because newUserPanel is new Thread, so it both happens at
the same time. How may I stop serialization until new User is confirmed?

No comments:

Post a Comment