There is no mouse listener in JToolBar.
You would use MouseListener to handle mouseEntered and mouseExited .
But you will have a problem, because mouse events will be passed only to the visible component. Therefore, as soon as you hide the toolbar, you will not receive the mouseEntered event.
Therefore, I do not understand your design. Are you planning to move other components to fill the space on the toolbar? Or do you just leave empty space? In the latter case, you will need to add MouseMotionListener to the panel and handle the mouseMoved event to see that the mouse is in the place where the toolbar should be.
source share