GenerateGroupsWindow window = new GenerateGroupsWindow(); window.show();
try { UserFilter filter = new UserFilter(); filter.setIdFormation(mainFrame.getFormationSelected().getIdFormation()); Collection students = DaoManager.getUserDao().getStudents(filter);  if (students.size() == 0) { JOptionPane.showMessageDialog(null, "Aucun tudiant n'a t trouv pour cette formation", "Erreur", JOptionPane.ERROR_MESSAGE); return; }  GenerateGroupsWindow window = new GenerateGroupsWindow(students.size()); window.show();  if (window.isOk()) { Collection groups = window.getNameGroups(); User[] stud = (User[]) students.toArray(new User[students.size()]); int j = 0; int nbStudentsByGroup = students.size() / groups.size(); int surplus = students.size() - nbStudentsByGroup * groups.size(); for (Iterator i = groups.iterator(); i.hasNext(); ) { Group group = new Group(); group.setHeading((String) i.next()); group.setIdFormation(mainFrame.getFormationSelected().getIdFormation()); int k; for (k = 0; k < nbStudentsByGroup; ++k) group.addStudent(stud[k+j]); if (surplus > 0) { group.addStudent(stud[k+j]); --surplus; ++j; } j += nbStudentsByGroup;  DaoManager.getGroupDao().addGroup(group); }  JOptionPane.showMessageDialog(null, "Ajouts effectus avec succs", "Information", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Une erreur interne est survenue", "Erreur", JOptionPane.ERROR_MESSAGE); }
    public void actionPerformed(ActionEvent arg0) {        GenerateGroupsWindow window = new GenerateGroupsWindow();        window.show();    }