-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b12
-
x86
-
linux, windows
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux andromeda.basis.com 2.6.12-1.1398_FC4 #1 Fri Jul 15 00:52:32 EDT 2005 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
BasicScrollBarUI.ArrowButtonListener starts a timer in mousePressed(), and stops it in mouseReleased(). If the frame containing the scrollbar is disabled between the MOUSE_PRESSED and the MOUSE_RELEASED events, the mouseReleased() method is never called. If the frame is then re-enabled, the still-running timer causes it to scroll all the way to the end. The sample program is informative.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run 'java DisableFrameFromScrollBar'
2. Click on the bottom scroll-button as though intending to move one unit down.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the scroll bar to remain motionless and the scroll button to be unpressed after the frame is re-enabled.
ACTUAL -
The scrollbar thumb moves all the way to the bottom, and the button remains pressed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
(None)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class DisableFrameFromScrollBar
{
public static void main(String[] args)
{
JFrame frame = new JFrame(DisableFrameFromScrollBar.class.getName());
JScrollBar bar = new JScrollBar();
bar.getModel().addChangeListener(new DisableChangeListener(frame));
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(bar);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
}
public static class DisableChangeListener implements ChangeListener
{
private final JFrame m_frame;
private boolean m_done = false;
public DisableChangeListener(JFrame p_frame)
{
m_frame = p_frame;
}
public void stateChanged(ChangeEvent p_e)
{
if (! m_done)
{
m_frame.setEnabled(false);
Thread t = new Thread(new Enabler(m_frame));
t.start();
m_done = true;
}
}
}
public static class Enabler implements Runnable
{
private JFrame m_frame;
Enabler(JFrame p_frame)
{ m_frame = p_frame; }
public void run()
{
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
m_frame.setEnabled(true);
}
}
}
---------- END SOURCE ----------
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux andromeda.basis.com 2.6.12-1.1398_FC4 #1 Fri Jul 15 00:52:32 EDT 2005 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
BasicScrollBarUI.ArrowButtonListener starts a timer in mousePressed(), and stops it in mouseReleased(). If the frame containing the scrollbar is disabled between the MOUSE_PRESSED and the MOUSE_RELEASED events, the mouseReleased() method is never called. If the frame is then re-enabled, the still-running timer causes it to scroll all the way to the end. The sample program is informative.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run 'java DisableFrameFromScrollBar'
2. Click on the bottom scroll-button as though intending to move one unit down.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the scroll bar to remain motionless and the scroll button to be unpressed after the frame is re-enabled.
ACTUAL -
The scrollbar thumb moves all the way to the bottom, and the button remains pressed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
(None)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class DisableFrameFromScrollBar
{
public static void main(String[] args)
{
JFrame frame = new JFrame(DisableFrameFromScrollBar.class.getName());
JScrollBar bar = new JScrollBar();
bar.getModel().addChangeListener(new DisableChangeListener(frame));
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(bar);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
}
public static class DisableChangeListener implements ChangeListener
{
private final JFrame m_frame;
private boolean m_done = false;
public DisableChangeListener(JFrame p_frame)
{
m_frame = p_frame;
}
public void stateChanged(ChangeEvent p_e)
{
if (! m_done)
{
m_frame.setEnabled(false);
Thread t = new Thread(new Enabler(m_frame));
t.start();
m_done = true;
}
}
}
public static class Enabler implements Runnable
{
private JFrame m_frame;
Enabler(JFrame p_frame)
{ m_frame = p_frame; }
public void run()
{
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
m_frame.setEnabled(true);
}
}
}
---------- END SOURCE ----------
- links to
-
Commit(master) openjdk/jdk/cafb3dc4
-
Review(master) openjdk/jdk/20346