JDK-6244705 : REGRESSION: Page down functionality for JTextArea in JScrollpane
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_10,windows_xp
  • CPU: x86,sparc
  • Submitted: 2005-03-23
  • Updated: 2011-01-19
  • Resolved: 2006-04-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b80Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
On Windows:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

On Linux:

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

Linux gaz 2.4.18 #18 SMP Mon Feb 24 11:42:05 EST 2003 i686 unknown

A DESCRIPTION OF THE PROBLEM :
If page down is hit more times than it takes to get to the bottom of the text area, the text area will scroll back up slightly leaving the window not quite at the bottom.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and run the code provided.
hit page down 3-4 times.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the scrollbar to be at the bottom of the window
ACTUAL -
after getting to the bottom of the window, hitting page down again scrolls the window back up 1/2 to 1 whole line of text.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/* Copyright 2004 The MathWorks, Inc.
 * $Revision: $
 */

/**
 * Created by: kthomas
 * Date: Nov 11, 2004
 */
import javax.swing.*;
import java.awt.Font;

public class TestTextArea {

    public TestTextArea()
    {
        JFrame frame = new JFrame("Text Area");
        JTextArea textArea = new JTextArea();
        textArea.setLineWrap(false);
        
        String s = new String("This is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.\nThis is text to display.");
        textArea.setText(s);
        
        JScrollPane sp = new JScrollPane(textArea);
        frame.getContentPane().add(sp);
        frame.getAccessibleContext().setAccessibleName("the frame");
        frame.setSize(250,300);
        frame.setLocation(300,300);
        frame.setVisible(true);

    }

    public static void main(String[] args)
    {
        new TestTextArea();
    }


}

---------- END SOURCE ----------

Release Regression From : 5.0
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-03-23 06:55:07 GMT

Comments
SUGGESTED FIX Webrev: http://javaweb.sfbay/jcg/1.6.0-mustang/swing/6244705
31-03-2006

EVALUATION The third parameter to constrainY() should be the height of the visible area, not the scroll amount. (Scroll amount is adjusted to be a multiple of font height.) When calculating the scroll amount, i also suggest to round towards lower integer, not the upper one. Otherwise, if there's a partially visible line at the bottom, and we hit PageDn, that line goes off screen. I've also fixed threading in the test -- it was failing intermittently.
28-03-2006

EVALUATION This is a regression caused by fix for 4697612
02-08-2005