I am seeing some behavior I really do not understand. In the first bit of code, when run() is called, the JFrames pop up, and the JPanels populate. In the second bit of code, the JFrames pop up but the JFrames do not populate and the windows seem irresponsive.
final Class g = TowerView.class
final ArrayList<Class> s = (ArrayList<Class>) sorters.clone();
final Quantifiable [] d = InventoryItem.getRandomArray(SIZE);
run (s, g, d);
This does NOT work:
final Class g = TowerView.class
final ArrayList<Class> s = (ArrayList<Class>) sorters.clone();
final Quantifiable [] d = InventoryItem.getRandomArray(SIZE);
runButton.addMouseListener(new MouseAdapter() {
@SuppressWarnings("unchecked")
public void mouseClicked(MouseEvent event) {
run(s, g, d);
}
});
You need to do the operation inside event listener i.e, run(s,g,d) command in another thread.
Excerpt from http://docs.oracle.com/javase/tutorial/uiswing/events/generalrules.html