I want to perform some actions when the mouse is over JMenuItem. Which listener should I use?

I want to perform some actions when the mouse is over JMenuItem. Which listener should I use?

+2
source share
3 answers

Use MouseListener . Its mouseEntered () and mouseExited () methods will be useful to you.

+5
source

If "some action" occurs, "show message", see JComponent.setToolTipText (String) .

+2
source

and alternative

menuItem1.getModel().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { ButtonModel model = (ButtonModel) e.getSource(); if (model.isRollover()) { // some stuff }// may be another states from ButtonModel } }); 
+2
source

All Articles