user3181103
user3181103

Reputation: 113

Java/Swing: Mouse cursor doesn't change when over component

in my application the mouse cursor does not change when over text field or other components (eg table resize).

The class MainWindow implements ActionListener and ListSelectionListener, could there be a cause? I never used MouseMotionListener or others.

Any ideas what could be the cause? Thanks

Edit:

Found cause: A panel containing the components was set disabled, the components worked fine, but the cursor didn't change when moving hover as the panel seems to be in charge of triggering that. maybe this post helps other lost souls

Upvotes: 1

Views: 1113

Answers (1)

Poly Hamza
Poly Hamza

Reputation: 159

You can try the following code (replace label_3 by your text field) :

Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); 
label_3.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
frame.setCursor(cursor);
                }
}

Upvotes: 1

Related Questions