下面是我试图实现的,但它在提到的行上给出了错误;这是因为函数没有得到哪个 Component.getName() 属于... String name=new String();
mntmOneToOne.addMouseListener(new MouseAdapter()
{
@Override
public void mouseClicked(MouseEvent arg0)
{
String name=new String();
int count = arg0.getClickCount();
if (count == 1)
{
Component panel = (Component) arg0.getSource();
System.out.println(panel.getName());
}
}
});