我有以下代码:
ActionListener listenerComboVehicle = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
comboVehicle.removeActionListener(listenerComboVehicle);
frameCrewSelection.removeAll();
frameCrewSelection.add(formCrewSelectionForm(SpaceObjectArray.findMannedByName(comboVehicle.getSelectedItem().toString()))); //Create some controls (Jcombobox comboVehicle included) and assign listeners to them.
formComboCrews(); //Modify JCombobox controls content
}
};
我的应用程序挂在以下代码上EventDispatchThread.java
:
void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
addEventFilter(filter);
while (doDispatch && cond.evaluate()) {
if (isInterrupted() || !pumpOneEventForFilters(id)) {
doDispatch = false;
}
}
removeEventFilter(filter);
}
while 循环是无限的,它会挂起我的应用程序。当.removeAll()
不存在时,应用程序不会挂起,但我会在旧控件上获得新控件。我通过布置一个框架并再次创建它找到了一种解决方法,但它看起来很讨厌。如果需要,将提供其他代码。请帮忙。