Listener_Thing_List_Editor_Button Listener_Refresh=Application_Context.getBean(Listener_Thing_List_Editor_Button.class);
.......
請問如何在不關閉容器的情形下銷毀某個bean(例如 Listener_Refresh) ?
謝謝兩位關注,不過也許沒有把問題說清楚,兩位的建議無法解決問題。
我試再把問題詳述如下:
上述的listener 放在一個 button 上,button放在splitpane上
以下是關閉splitpane的代碼:
public Boolean Set_component_user_wants_to_cancel_all()
{
Boolean OK=true;
if(Sure_to_cancel)
{
this.removeAll(); //"this"=splitpane
Listener_Refresh=null;
}
else
{
...........
OK=false;
}
return OK;
}
以下是listener的代碼:
@org.springframework.stereotype.Component
@Scope("prototype")
public class Listener_Thing_List_Editor_Button implements ActionListener
{
private Mirror_World_Dispatcher Mirror_World_Dispatcher=null;
public Listener_Thing_List_Editor_Button()
{
}
public void setMirror_World_Dispatcher(Mirror_World_Dispatcher Mirror_World_Dispatcher)
{
this.Mirror_World_Dispatcher=Mirror_World_Dispatcher;
}
public void actionPerformed(ActionEvent e)
{
this.Mirror_World_Dispatcher.React_to_thing_list_editor_action_event(e,null);
}
}
問題是,如果我重複 “關閉splitpane,打開splitpane,按button”過程 n次,actionPerformed則會被執行n次。
所以我懷疑執行上述Set_component_user_wants_to_cancel_all()后,Listener_Refresh實例依然存在。