JDK-4118621 : Selected text scrolls text out of view even if there is enough room
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-03-11
  • Updated: 1999-07-20
  • Resolved: 1999-07-20
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 Other
1.1.8 1.1.8Fixed 1.2.2Fixed
Related Reports
Relates :  
Relates :  
Description

Name: chT40241			Date: 03/11/98


Problem: TextField scrolls selected text out of view although the
TextField is wide enough to display all text.  This problem occurs only if the text is selected.  In addition, the problem appears to be related to the length of the text with a text length of 13 or greater causing a problem.

Compile and run this code to see that the text is scrolled such that "fghijklmnop" is displayed and highlighted instead of the whole text string as happens on the Microsoft VM.

import java.awt.*;
import java.awt.event.*;

public class TestTextField implements WindowListener {
  Frame fr = new Frame("TestTextField");
  public TestTextField() {
      fr.setSize(300,300);
      TextField tf = new TextField("", 35);
      fr.add(tf, "Center");
      String s = "abcdefghijklmnop";
      tf.setText(s);
      //tf.select(0, s.length());
      fr.addWindowListener(this);
      fr.setVisible(true);
  }
  public void windowOpened(WindowEvent e) {}
  public void windowClosing(WindowEvent e) {
      fr.dispose();
  }
  public void windowClosed(WindowEvent e) {
      System.exit(0);
  }
  public void windowIconified(WindowEvent e) {}
  public void windowDeiconified(WindowEvent e) {}
  public void windowActivated(WindowEvent e) {}
  public void windowDeactivated(WindowEvent e) {}
  public static void main(String[] args) {
      new TestTextField();
  }
}

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.1.8 1.2.2 FIXED IN: 1.1.8 1.2.2 INTEGRATED IN: 1.1.8 1.2.2 VERIFIED IN: 1.1.8
14-06-2004

WORK AROUND Name: chT40241 Date: 03/11/98 None ======================================================================
11-06-2004

SUGGESTED FIX Name: rpC71689 Date: 11/13/98 prs@russia Override Reshape method in class AwtTextComponent so that every time we resize the edit control we also renew the selection. ======================================================================
11-06-2004

EVALUATION Name: rpC71689 Date: 11/13/98 prs@russia Let's see the sequence of calls that occurs when we make the Frame visible for the first time. setVisible(boolean) method on Frame calls show() method on window, which looks like the following: public void show() { ... if (peer == null) { addNotify(); } validate(); ... } Here we see, that addNotify(), which also creates peers for the children of the Window, is called before validate(). Native select is called on the peer of the textfield during its creation, but textfield's size is incorrect at that moment. The correct size that we see on the screen is only set later in validate(), exactly in layoutContainer() method of LayoutManager, but the selection is not renewed since it is set during peer initialization. ====================================================================== This bus was verified as fixed via regression testing using jdk118f. al.smith@eng 1999-02-05
05-02-1999