2011-04-11 61 views
0

我想關閉一個彈出面板,點擊一個錨點,但這個錨點可能在幾個面板內,然後通過父母並不是一個好主意。GWT正確關閉彈出式面板?

我該如何獲得錨點所在的彈出面板?

回答

2

將​​的變量傳遞給其他面板,怎麼樣?

public class PanelWithPopup extends Composite 
{ 
    FlowPanel thisPanel = new FlowPanel(); 
    PopupPanel popup = new PopupPanel(); 
    SomeOtherPanel otherPanel; 

    public PanelWithPopup() 
    { 
     // pass the popup panel to the SomeOtherPanel 
     otherPanel = new SomeOtherPanel(popup); 

     thisPanel.add(otherPanel); 
     initWidget(thisPanel); 
    } 
} 

public class SomeOtherPanel 
{ 
    PopupPanel popup; 

    public SomeOtherPanel(PopupPanel p) 
    { 
     this.popup = p; 
    } 

    void hidePopup() 
    { 
     popup.hide(); 
    } 
} 

或者,如果其他的板的主面板內限定(即,如果SomeOtherPanel是在PanelWithPopup內定義),可以直接訪問PopupPanel popup