-
Bug
-
Resolution: Unresolved
-
P3
-
8u20, 9.0.4, 10
-
x86_64
-
os_x
FULL PRODUCT VERSION :
1.8.161, also seen with 1.9.0.4.0.11
ADDITIONAL OS VERSION INFORMATION :
Mac OS 10.12, also seen in earlier versions
A DESCRIPTION OF THE PROBLEM :
When the cursor has been changed to something other than the pointer, and the current application is changed using CMD+Tab, and then the current application is changed back again with CMD+Tab, all without moving the mouse, then the cursor stays the pointer.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 run attached code
2 click in one of the cursor boxes to change the cursor to 'hand' or 'text'
3 move the cursor outside the cursor select box, cursor changes appearance
4 without moving the mouse, press CMD+Tab to leave the application, cursor changes to pointer
5 without moving the mouse, press CMD+Tab again to return to the test application, cursor stays pointer
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Cursor should change back to the 'hand' or 'text' cursor
ACTUAL -
cursor stays pointer
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.*;
import javax.swing.*;
public class test extends JFrame {
public static final Cursor pointerCursor = Cursor.getDefaultCursor();
public static final Cursor handCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
public static final Cursor textCursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR);
private cursorChooser currentCursorChooser;
public test() {
super("Test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
setSize(400, 400);
cursorChooser pointerCC = new cursorChooser(this, pointerCursor, "Pointer");
cursorChooser handCC = new cursorChooser(this, handCursor, "Hand");
cursorChooser textCC = new cursorChooser(this, textCursor, "Text");
int x = 5;
int y = 5;
pointerCC.setLocation(x, y);
y += cursorChooser.kChooserHeight - 1;
handCC.setLocation(x, y);
y += cursorChooser.kChooserHeight - 1;
textCC.setLocation(x, y);
add(pointerCC);
add(handCC);
add(textCC);
currentCursorChooser = pointerCC;
selectCursor(currentCursorChooser);
setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@SuppressWarnings("unused")
public void run() {
new test();
}
});
}
public void selectCursor(cursorChooser cc) {
setCursor(cc.crsr);
currentCursorChooser.setSelected(false);
currentCursorChooser = cc;
currentCursorChooser.setSelected(true);
repaint();
}
}
class cursorChooser extends JComponent {
public static final int kChooserWidth = 110;
public static final int kChooserHeight = 20;
private static final int textWidth = 90;
private test parent;
private JLabel text;
public Cursor crsr;
private boolean isSelected = false;
cursorChooser(test par, Cursor c, String title) {
super();
parent = par;
crsr = c;
setLayout(null);
setSize(kChooserWidth, kChooserHeight + 1);
setCursor(test.pointerCursor);
text = new JLabel(title);
text.setBounds(kChooserHeight + 10, 0, textWidth, kChooserHeight);
add(text);
MouseListener ml = new MouseListener();
addMouseListener(ml);
}
public void setSelected(boolean isSelect) {
isSelected = isSelect;
repaint();
}
@Override
public void paintComponent(Graphics g) {
if (isSelected) {
g.setColor(Color.YELLOW);
g.fillRect(0, 0, kChooserHeight + textWidth - 1, kChooserHeight);
}
g.setColor(Color.BLACK);
g.drawRect(1, 1, kChooserHeight + textWidth - 2, kChooserHeight - 1);
}
class MouseListener extends MouseAdapter {
@Override
public void mouseClicked(MouseEvent e) {
parent.selectCursor(cursorChooser.this);
}
}
}
---------- END SOURCE ----------
1.8.161, also seen with 1.9.0.4.0.11
ADDITIONAL OS VERSION INFORMATION :
Mac OS 10.12, also seen in earlier versions
A DESCRIPTION OF THE PROBLEM :
When the cursor has been changed to something other than the pointer, and the current application is changed using CMD+Tab, and then the current application is changed back again with CMD+Tab, all without moving the mouse, then the cursor stays the pointer.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 run attached code
2 click in one of the cursor boxes to change the cursor to 'hand' or 'text'
3 move the cursor outside the cursor select box, cursor changes appearance
4 without moving the mouse, press CMD+Tab to leave the application, cursor changes to pointer
5 without moving the mouse, press CMD+Tab again to return to the test application, cursor stays pointer
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Cursor should change back to the 'hand' or 'text' cursor
ACTUAL -
cursor stays pointer
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.*;
import javax.swing.*;
public class test extends JFrame {
public static final Cursor pointerCursor = Cursor.getDefaultCursor();
public static final Cursor handCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
public static final Cursor textCursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR);
private cursorChooser currentCursorChooser;
public test() {
super("Test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
setSize(400, 400);
cursorChooser pointerCC = new cursorChooser(this, pointerCursor, "Pointer");
cursorChooser handCC = new cursorChooser(this, handCursor, "Hand");
cursorChooser textCC = new cursorChooser(this, textCursor, "Text");
int x = 5;
int y = 5;
pointerCC.setLocation(x, y);
y += cursorChooser.kChooserHeight - 1;
handCC.setLocation(x, y);
y += cursorChooser.kChooserHeight - 1;
textCC.setLocation(x, y);
add(pointerCC);
add(handCC);
add(textCC);
currentCursorChooser = pointerCC;
selectCursor(currentCursorChooser);
setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@SuppressWarnings("unused")
public void run() {
new test();
}
});
}
public void selectCursor(cursorChooser cc) {
setCursor(cc.crsr);
currentCursorChooser.setSelected(false);
currentCursorChooser = cc;
currentCursorChooser.setSelected(true);
repaint();
}
}
class cursorChooser extends JComponent {
public static final int kChooserWidth = 110;
public static final int kChooserHeight = 20;
private static final int textWidth = 90;
private test parent;
private JLabel text;
public Cursor crsr;
private boolean isSelected = false;
cursorChooser(test par, Cursor c, String title) {
super();
parent = par;
crsr = c;
setLayout(null);
setSize(kChooserWidth, kChooserHeight + 1);
setCursor(test.pointerCursor);
text = new JLabel(title);
text.setBounds(kChooserHeight + 10, 0, textWidth, kChooserHeight);
add(text);
MouseListener ml = new MouseListener();
addMouseListener(ml);
}
public void setSelected(boolean isSelect) {
isSelected = isSelect;
repaint();
}
@Override
public void paintComponent(Graphics g) {
if (isSelected) {
g.setColor(Color.YELLOW);
g.fillRect(0, 0, kChooserHeight + textWidth - 1, kChooserHeight);
}
g.setColor(Color.BLACK);
g.drawRect(1, 1, kChooserHeight + textWidth - 2, kChooserHeight - 1);
}
class MouseListener extends MouseAdapter {
@Override
public void mouseClicked(MouseEvent e) {
parent.selectCursor(cursorChooser.this);
}
}
}
---------- END SOURCE ----------