-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler
@version 1.28 04/10/06
A DESCRIPTION OF THE PROBLEM :
javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler
@version 1.28 04/10/06
Under certain circumstances the spinner could lose its normal expected spin-behavior, in particulary by changing the look and feel (calling SwingUtilities.updateComponentTreeUI(spinner)).
The Bug is located in the ArrowButtonHandler in BasicSpinnerUI.class in the method public void actionPerformed(ActionEvent e) {
...
else {
if (arrowButton != null && !arrowButton.getModel().isPressed()
&& autoRepeatTimer.isRunning()) {
//the bug has its cause here
...
}
...
}
Under certain circumstances the arrowButton is missed to set to the null, after a spin-action is finished.
If you change now the look and feel, and press and hold the arrow-button, the spinner does not start spinning as expected. Instead it stops instantly spinning and runs in the above part of the code, because it holds a reference to the old arraowButton which delivers arrowButton.getModel().isPressed()=false but this is not the button which i press. Its the old one and not the newone currently pressed-arrow-button!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Click and hold pressed with the left mouse-button on the upper button (arrow) of the spinner until it spins.
2. call SwingUtilities.updateComponentTreeUI(spinner)
3. repeat step 1.
4. repeat step 2.
5. Click and hold pressed the left mouse-button, the upper button of the spinner -> the bug occurs and the spinner does not beginn to spin as normaly expected!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After changing the look and feel the spinner should always spin and stayed spinning, when i click and hold pressed the arrow-button. Also on the first click. Only when i release the mouse, then it should stop spinning.
ACTUAL -
Setting the arrowButton allways to null, after a spinning-action is complete. Alternativ set it to null when SwingUtilities.updateComponentTreeUI(spinner) is called!
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class BasicSpinnerUIBug {
public static void main(String args[]) throws Exception {
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
if (lookAndFeels.length < 2) {
System.out.println("You need at least 2 look and feels to complete the test!");
System.exit(-1);
}
final LookAndFeel lfs[] = new LookAndFeel[2];
lfs[0] = (LookAndFeel) Class.forName(lookAndFeels[0].getClassName()).newInstance();
lfs[1] = (LookAndFeel) Class.forName(lookAndFeels[1].getClassName()).newInstance();
final JFrame frm = new JFrame();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setPreferredSize(new Dimension(600, 300));
frm.getContentPane().setLayout(new FlowLayout());
final JSpinner spinner = new JSpinner();
spinner.setPreferredSize(new Dimension(60, 20));
JButton btn = new JButton("provoke bug");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.updateComponentTreeUI(spinner);
}
});
JLabel l = new JLabel("<html>1. click and hold pressed with the left mouse-button on the <br/>upper button (arrow) of the spinner until it spins<br/><br/>" +
"2. click on the provokate bug button<br/><br/>" +
"3. click and hold pressed with the left mouse-button on the <br/>upper button (arrow) of the spinner until it spins<br/><br/>" +
"4. click on the provokate bug button<br/><br/>" +
"5. click and hold pressed the left mouse-button, the upper button of the spinner <br/> -> the bug occurs and the spinner does not beginn to spin!</html>");
frm.getContentPane().add(spinner);
frm.getContentPane().add(btn);
frm.getContentPane().add(l);
frm.pack();
frm.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As described in Bug #4840869 after calling SwingUtilities.updateComponentTreeUI(spinner) call releaseMouse(JSpinner) is setting indirectly the member-variable of javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler to null.
But this is only to proof the bug, and not a real solution, it could cause a lot other side effects. As javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler is hold in a static member field, its sufficient to call releaseMouse(JSpinner) only on one spinner, and every other spinner will function also as expected (the ArrowButtonHandler instance is shared beetween all, and has now set the arrowButton variable to null).
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler
@version 1.28 04/10/06
A DESCRIPTION OF THE PROBLEM :
javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler
@version 1.28 04/10/06
Under certain circumstances the spinner could lose its normal expected spin-behavior, in particulary by changing the look and feel (calling SwingUtilities.updateComponentTreeUI(spinner)).
The Bug is located in the ArrowButtonHandler in BasicSpinnerUI.class in the method public void actionPerformed(ActionEvent e) {
...
else {
if (arrowButton != null && !arrowButton.getModel().isPressed()
&& autoRepeatTimer.isRunning()) {
//the bug has its cause here
...
}
...
}
Under certain circumstances the arrowButton is missed to set to the null, after a spin-action is finished.
If you change now the look and feel, and press and hold the arrow-button, the spinner does not start spinning as expected. Instead it stops instantly spinning and runs in the above part of the code, because it holds a reference to the old arraowButton which delivers arrowButton.getModel().isPressed()=false but this is not the button which i press. Its the old one and not the newone currently pressed-arrow-button!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Click and hold pressed with the left mouse-button on the upper button (arrow) of the spinner until it spins.
2. call SwingUtilities.updateComponentTreeUI(spinner)
3. repeat step 1.
4. repeat step 2.
5. Click and hold pressed the left mouse-button, the upper button of the spinner -> the bug occurs and the spinner does not beginn to spin as normaly expected!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After changing the look and feel the spinner should always spin and stayed spinning, when i click and hold pressed the arrow-button. Also on the first click. Only when i release the mouse, then it should stop spinning.
ACTUAL -
Setting the arrowButton allways to null, after a spinning-action is complete. Alternativ set it to null when SwingUtilities.updateComponentTreeUI(spinner) is called!
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class BasicSpinnerUIBug {
public static void main(String args[]) throws Exception {
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
if (lookAndFeels.length < 2) {
System.out.println("You need at least 2 look and feels to complete the test!");
System.exit(-1);
}
final LookAndFeel lfs[] = new LookAndFeel[2];
lfs[0] = (LookAndFeel) Class.forName(lookAndFeels[0].getClassName()).newInstance();
lfs[1] = (LookAndFeel) Class.forName(lookAndFeels[1].getClassName()).newInstance();
final JFrame frm = new JFrame();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setPreferredSize(new Dimension(600, 300));
frm.getContentPane().setLayout(new FlowLayout());
final JSpinner spinner = new JSpinner();
spinner.setPreferredSize(new Dimension(60, 20));
JButton btn = new JButton("provoke bug");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.updateComponentTreeUI(spinner);
}
});
JLabel l = new JLabel("<html>1. click and hold pressed with the left mouse-button on the <br/>upper button (arrow) of the spinner until it spins<br/><br/>" +
"2. click on the provokate bug button<br/><br/>" +
"3. click and hold pressed with the left mouse-button on the <br/>upper button (arrow) of the spinner until it spins<br/><br/>" +
"4. click on the provokate bug button<br/><br/>" +
"5. click and hold pressed the left mouse-button, the upper button of the spinner <br/> -> the bug occurs and the spinner does not beginn to spin!</html>");
frm.getContentPane().add(spinner);
frm.getContentPane().add(btn);
frm.getContentPane().add(l);
frm.pack();
frm.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As described in Bug #4840869 after calling SwingUtilities.updateComponentTreeUI(spinner) call releaseMouse(JSpinner) is setting indirectly the member-variable of javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler to null.
But this is only to proof the bug, and not a real solution, it could cause a lot other side effects. As javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler is hold in a static member field, its sufficient to call releaseMouse(JSpinner) only on one spinner, and every other spinner will function also as expected (the ArrowButtonHandler instance is shared beetween all, and has now set the arrowButton variable to null).