Java JFrame removeall挂起应用程序 [英] Java JFrame removeall hangs an application
问题描述
我有以下代码:
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()
不存在时,应用程序不会挂起,但我获得了旧控件的新控件。我找到一个解决方法,通过处置一个框架,并再次创建,但它看起来很讨厌。如果需要,将提供附加代码。请帮助。
The while loop is infinite and it hangs my application. When .removeAll()
is absent, the application doesn't hang but I get new controls over old controls. I've found a workaround by disposing a frame and creating it again but it looks nasty. Additional code will be provided if needed. Please help.
推荐答案
从评论中移除更好的视图:
Moved from comments for better view:
frameCrewSelection.getContentPane()。removeAll(); frameCrewSelection.setContentPane(formCrewSelectionForm(SpaceObjectArray.findMan nedByName(comboVehicle.getSelectedItem()。toString())));
。
这篇关于Java JFrame removeall挂起应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!