JAVA GUI学习 - JPopupMenu鼠标右键菜单组件学习

public class JPopmenuKnow
{
public void test()
{
//为表格添加鼠标右键菜单
JMenuItem jMenuItemFileInfo = new JMenuItem("文件属性");jMenuItemFileInfo.setName("jMenuItemFileInfo");
JMenuItem jMenuItemOpenFile = new JMenuItem("打开文件");jMenuItemOpenFile.setName("jMenuItemOpenFile");
JPopupMenu jPopupMenuFileInfo = new JPopupMenu();
jPopupMenuFileInfo.add(jMenuItemFileInfo);jPopupMenuFileInfo.add(jMenuItemOpenFile);
JTable jTableFiles = new JTable();
jTableFiles.setComponentPopupMenu(jPopupMenuFileInfo); //添加监听器
JPopmenuActionListener jPopmenuActionListener = new JPopmenuActionListener();
jMenuItemFileInfo.addActionListener(jPopmenuActionListener);
jMenuItemOpenFile.addActionListener(jPopmenuActionListener);
}
private class JPopmenuActionListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent e)
{ }
}
}
上一篇:卷积神经网络系列之softmax,softmax loss和cross entropy的讲解


下一篇:cosface: large margin cosine loss for deep face recognition