JDK-6254133 : Setting cursor to not-default does not work in Dialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_1
  • CPU: sparc
  • Submitted: 2005-04-12
  • Updated: 2005-05-26
  • Resolved: 2005-05-26
Related Reports
Duplicate :  
Description
Here is the test case:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class ActionLabel extends JLabel implements MouseListener{
    private Color originalColor;
    private Cursor handCursor = new Cursor(Cursor.HAND_CURSOR); 
    private Cursor originalCursor = null;

    ActionLabel(String text, Color c){
      super(text);
      setForeground(c);
      addMouseListener(this);
      originalColor = c;
System.out.println("getCursor="+getCursor());
setCursor(handCursor);System.out.println("getCursor="+getCursor());
    }

    public void mouseClicked(MouseEvent e) {
      // Do something when user clicks on label...
    }
	 
    public void mouseEntered(MouseEvent e) {
       setForeground(Color.RED);
    }

    public void mouseExited(MouseEvent e) {
        if(originalColor != null)
	  setForeground(originalColor);
    }
	
    public void mousePressed(MouseEvent e) {	
    } 
    public void mouseReleased(MouseEvent e) {
    }    


 public static void main(String [] args){
    JDialog test = new JDialog();
    ActionLabel details = new ActionLabel("Details...", Color.blue);
    test.getContentPane().add(details);
    test.pack();
    test.setVisible(true);
  }
}


In println I get the HAND_CURSOR, but on screen, the cursor does not change to HAND_CURSOR.  Works with JRE 1.4.2_01.  I did not try it with 1.5.0.  Also works fine with JFrame instead of JDialog in 1.6.0.
###@###.### 2005-04-12 18:35:33 GMT

Comments
EVALUATION looks like a duplicate of 5079694 ###@###.### 2005-04-13 06:18:41 GMT This is indeed a duplicate of 5079694. Cursor can't be set on any swing components which do not have a Frame ancestor. ###@###.### 2005-05-26 12:37:09 GMT
13-04-2005