日期:2014-05-20  浏览次数:20544 次

怎么判断事件源是框体

如果实践源是框体就关闭框体,如果事件源是对话框就关闭对话框,怎么实现??  

public   class   CloseWin   extends   WindowAdapter  
{  
public   void   windowClosing(WindowEvent   e)  
{  
if()//实践源是一框体  
{  
((Frame)e.getSource()).dispose();  
System.exit(0);  
}  
else   if()//事件源是对话框  
((Dialog)e.getSource()).dispose();  

}  
}

------解决方案--------------------
e.getSource().getClass()