JAVAJMenu的操作侦听器
如何为JAVAJMenu的操作侦听器,java,swing,actionlistener,jmenu,Java,Swing,Actionlistener,Jmenu,如何为JMenu(而不是JMenuItem)添加操作侦听器?我想单击此菜单打开新窗口。多谢各位 您可以尝试此选项,并可以向JMenu添加一个操作侦听器 menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //Execute when JMenu is pressed System.out.println("You cl
JMenu
(而不是JMenuItem
)添加操作侦听器?我想单击此菜单打开新窗口。多谢各位 您可以尝试此选项,并可以向JMenu添加一个操作侦听器
menu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//Execute when JMenu is pressed
System.out.println("You clicked the JMenu");
}
});
:看一看从类javax.swing.AbstractButtonOK继承的名为Methods的部分,非常感谢!你试过添加鼠标侦听器吗?奎师那,谢谢你!我明白了。@user3649515我的荣幸:)这没用。