如何为JMenu
(而不是JMenuItem
)添加动作监听器?我想在单击此菜单时打开新窗口。非常感谢你!
您可以尝试这一操作,还可以向JMenu添加一个动作侦听器。
menu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//Execute when JMenu is pressed
System.out.println("You clicked the JMenu");
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句