2013-07-15 22 views
1

如何在另一個Gui內啓動JADE Gui?假設我的Gui有一個按鈕。點擊該按鈕後,JADE Gui將開始。如何在另一個Gui內啓動JADE Gui?

這可能嗎?如果是,如何?

在此先感謝。

問候

+0

可能重複[如何使用JADE運行多個GUI?](http://stackoverflow.com/questions/17644517/how-to-run-multiple-guis-with-jade) –

回答

5

我假設由JADE桂你的意思是JADE RMA

由於RMA本身就是一個代理,顯示RMA GUI是簡單地創建和啓動RMA劑的問題。

如果您是通過代碼(即不通過命令行或GUI)執行此操作,則必須對要啓動的容器引用容器控制器,而您只會對其調用createAgent()方法。

import jade.wrapper.AgentController; 
import jade.wrapper.ContainerController; 

... 

ContainerController myContainer; 

// .. load a container into the above variable .. 

try { 
    AgentController rma = myContainer.createNewAgent("rma", "jade.tools.rma.rma", null); 
    rma.start(); 
} catch(StaleProxyException e) { 
    e.printStackTrace(); 
} 

您可以從代碼開始在主容器這樣

import jade.core.Runtime; 
import jade.core.Profile; 
import jade.core.ProfileImpl; 

... 

Runtime myRuntime = Runtime.instance(); 

// prepare the settings for the platform that we're going to start 
Profile myProfile = new ProfileImpl(); 

// create the main container 
myContainer = myRuntime.createMainContainer(myProfile); 

或者你也可以正常啓動劑容器,並連接到外部容器,這樣

import jade.core.Runtime; 
import jade.core.Profile; 
import jade.core.ProfileImpl; 

... 

Runtime myRuntime = Runtime.instance(); 

// prepare the settings for the platform that we're going to connect to 
Profile myProfile = new ProfileImpl(); 
myProfile.setParameter(Profile.MAIN_HOST, "myhost"); 
myProfile.setParameter(Profile.MAIN_PORT, "1099"); 

// create the agent container 
myContainer = myRuntime.createAgentContainer(myProfile); 

參考:發展帶JADE的多代理系統,Fabio Luigi Bellifemine,Giovanni Caire,Dominic Greenwood。