-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
sparc
-
solaris_1
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
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
- duplicates
-
JDK-5079694 JDialog doesn't respect setCursor
- Resolved