cqiao
26 Jun 2008, 4:42 AM
tow piece os code:
A:
menuItem1.addListener(Events.OnClick, new Listener<MenuEvent>(){
public void handleEvent(MenuEvent be)
{
if (be.getEventType()==Events.OnClick)
MessageBox.prompt("test","The event fired!");
}
});
B:
menuItem1.addSelectionListener(new SelectionListener<MenuEvent>(){
public void componentSelected(MenuEvent ce)
{
// TODO Auto-generated method stub
MessageBox.prompt("test","The event fired!");
}
//@Override
public void handleEvent(MenuEvent ce)
{
// TODO Auto-generated method stub
MessageBox.prompt("test","The event fired!");
}
});
===========================
why B works well, but A is not ?
A:
menuItem1.addListener(Events.OnClick, new Listener<MenuEvent>(){
public void handleEvent(MenuEvent be)
{
if (be.getEventType()==Events.OnClick)
MessageBox.prompt("test","The event fired!");
}
});
B:
menuItem1.addSelectionListener(new SelectionListener<MenuEvent>(){
public void componentSelected(MenuEvent ce)
{
// TODO Auto-generated method stub
MessageBox.prompt("test","The event fired!");
}
//@Override
public void handleEvent(MenuEvent ce)
{
// TODO Auto-generated method stub
MessageBox.prompt("test","The event fired!");
}
});
===========================
why B works well, but A is not ?