JDK-4666101 : 1.4.0 REGRESSION: JEditorPane: down arrow occasionally nonfunctional
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2002-04-10
  • Updated: 2022-03-04
  • Resolved: 2002-08-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.
Other
1.4.2 mantisFixed
Related Reports
Duplicate :  
Relates :  
Description

Name: jk109818			Date: 04/10/2002


FULL PRODUCT VERSION :
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)


FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]


ADDITIONAL OPERATING SYSTEMS :
SunOS (machine name) 5.8 Generic_108528-08 sun4u sparc
SUNW,Ultra-60



A DESCRIPTION OF THE PROBLEM :
In a JEditorPane, the down arrow has no effect after you
add text on a line preceding a blank line.


REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. In a JEditorPane, hit Return twice.
2. Type "test".
3. Hit the up arrow twice.
4. Type "test".
5. Hit the down arrow.


EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: Cursor moves down.

Actual: Nothing happens.



ERROR MESSAGES/STACK TRACES THAT OCCUR :
(none)

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/**
 * Tests a bug in JEditorPane which prevents the down arrow from working in
 * some cases.
 *
 * To demontrate the bug, do the following in the JEditorPane that appears:
 * 1. Hit return twice.
 * 2. Type "test".
 * 3. Hit the up arrow twice.
 * 4. Type "test".
 * 5. Hit the down arrow.
 */

import javax.swing.*;
import javax.swing.text.*;

public class TestBug {
  public static void main(String args[]) {
    JFrame f = new JFrame();
    JEditorPane jep = new JEditorPane();
    jep.setEditable(true);
    f.getContentPane().add(jep);
    f.setVisible(true);
    f.setSize(500, 500);
    f.setLocation(100,100);
  }
}

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

CUSTOMER WORKAROUND :
After typing text, use left or right arrows before using
down arrow.

Release Regression From : 1.3.1_03
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 145083) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis mantis-b02 FIXED IN: mantis mantis-b02 INTEGRATED IN: mantis mantis-b02
14-06-2004

EVALUATION Name: ik75403 Date: 08/01/2002 The arrow does not work because at some point View.getNextVisualPositionFrom get called with position -1 and direction NORTH or SOUTH. View does not know how to handle it. The better fix for the bug is to not use -1 for positions.According to the javadoc -1 is not allowed there. We can change javadoc or we can change the sources. We'll see what we can do for tiger. ======================================================================
11-06-2004

SUGGESTED FIX Name: ik75403 Date: 08/01/2002 *** /export2/kid/tiger/webrev/src/share/classes/javax/swing/text/View.java- Mon Jul 15 17:00:26 2002 --- View.java Mon Jul 15 15:03:15 2002 -------------------------------------------------------------------------------- *** 511,520 **** --- 511,525 ---- biasRet[0] = Position.Bias.Forward; switch (direction) { case NORTH: case SOUTH: { + if (pos == -1) { + pos = (direction == NORTH) ? Math.max(0, getEndOffset() - 1) : + getStartOffset(); + break; + } JTextComponent target = (JTextComponent) getContainer(); Caret c = (target != null) ? target.getCaret() : null; // YECK! Ideally, the x location from the magic caret position // would be passed in. Point mcp; ======================================================================
11-06-2004