gpt4 book ai didi

Java JFrame removeall 挂起应用程序

转载 作者:行者123 更新时间:2023-12-01 05:10:56 25 4
gpt4 key购买 nike

我有以下代码:

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() 不存在时,应用程序不会挂起,但我会在旧控件上获得新控件。我找到了一种解决方法,通过处理框架并再次创建它,但它看起来很糟糕。如果需要,将提供附加代码。请帮忙。

最佳答案

为了更好的 View 而从评论中移走:

frameCrewSelection.getContentPane().removeAll(); frameCrewSelection.setContentPane(formCrewSelectionForm(SpaceObjectArray.findMan‌​nedByName(comboVehicle.getSelectedItem().toString())));

成功了。

关于Java JFrame removeall 挂起应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12042039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com