FYI I adopted a mediation template for my GUI in Swing in Java.
Unfortunately, a parallel modification exception is always thrown if the user needs a new window.
This is because my code is trying to add a new colleague (new window) to the list of colleague intermediaries in the process of processing user input from an existing colleague (window).
eg.
public MainScreenColleague implements GuiColleague, ActionListener {
private GuiMediator mediator;
public MainScreenColleague(GuiMediator medi) {
mediator = medi;
}
public conveyInputToMediator(EventObject event) {
mediator.conveyInputToColleagues(event);
}
public receiveInputFromMediator(EventObject event) {
if (event.getSource() = particularBtn) {
GuiColleague particularColleague = new ParticularConcreteColleague(mediator);
mediator.addGuiColleague(particularColleague);
}
}
Is there any other management structure for adding new colleagues that I can accept? Thanks in advance for any suggestions or ideas.
source
share