Okay so, I have this function which I call on every JButton I create, and it works fine.
public void addcursor(JButton button)
{
button.getModel().addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
ButtonModel model=(ButtonModel) e.getSource();
if(model.isRollover())
setCursor(new Cursor(Cursor.HAND_CURSOR));
else
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
});
}
However, this code works only when I move over a JButton, and sets the mouse cursor back to default when I move away from the Button. So, on a separate class/function:
gui.getRootPane().setCursor(new Cursor(Cursor.WAIT_CURSOR));
gui.getRootPane().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
After calling those 2 functions, the first function addcursor(JButton) doesn't work anymore, I just want to set the buttons getModel back to how it was, after setting the cursor back to default. Note that I also tried re-calling the addcursoor(JButton) function after setting the crusor to default, but it still didn't work. Thank you.