mntmOneToOne.addMouseListener(new MouseAdapter()
{
@Override
public void mouseClicked(MouseEvent arg0)
{
String name=new String();
int count = arg0.getClickCount();
// selecting 1st panel
if (count == 1)
{
JPanel panel = (JPanel) arg0.getSource();
// name = panel.getName();
System.out.println(panel.getName());
}
// selecting the 2nd panel
if (count == 1)
{
JPanel panel = (JPanel) arg0.getSource();
// name = panel.getName();
System.out.println(panel.getName());
}
}
});
我想在点击mntmOnetoOne按钮时创建一个模式;在此模式下,在JFrame的5个面板中单击的任何两个面板将在控制台上显示其(JPanel的)名称。用户单击任意两个面板后,此模式将自动关闭。