Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5003402

REGRESSION: java.awt.TextArea stops scrolling when it loses the keyboard focus.

XMLWordPrintable

    • b10
    • x86
    • windows_xp

        Name: gm110360 Date: 02/25/2004


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


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


        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Use this HTML file for the applet below:

        <?xml version="1.0" encoding="us-ascii"?>
        <!DOCTYPE html
            PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
        <title>Test Applet</title>
        </head>
        <body>
        <h1>Test Applet</h1>
        <p>This is a test applet.</p>
        <p><applet code="TestApplet.class" width="300" height="100"></applet></p>
        </body>
        </html>


        A DESCRIPTION OF THE PROBLEM :
        When appending to a java.awt.TextArea, the vertical scroll bar automatically scrolls to see the last line appended when there is more text in the text area than will fit in the current size, regardless of which component has the focus. This works in Java version 1.0.2 through version 1.4.2_03.

        In Java 1.5.0 Beta 1, the automatic scrolling occurs only when the text area has the keyboard focus. That's a problem for things like chat clients which need the incoming messages to scroll in the text area while the outgoing message text field has the keyboard focus.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the applet included below with the Java 1.5.0 Beta 1 appletviewer program. Watch the automatic scrolling. Then click the text field at the bottom of the applet to give it the keyboard focus. Watch the automatic scrolling stop.

        In Java version 1.4.2_03 and earlier, the automatic scrolling continues even when the text area loses the keyboard focus.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The scrolling should continue even when the text area loses keyboard focus.

        ACTUAL -
        The scrolling stops when the text area loses keyboard focus.


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        None.


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.applet.*;
        import java.awt.*;

        public class TestApplet extends Applet implements Runnable {
            TextArea area;
            TextField field;
            Thread thread;

            public void init() {
                System.out.println("Initializing applet ...");
                area = new TextArea();
                field = new TextField();
                setLayout(new BorderLayout());
                add("Center", area);
                add("South", field);
                thread = new Thread(this);
            }

            public void start() {
                System.out.println("Starting applet ...");
                thread.start();
            }

            public void run() {
                try {
                    for (int i = 0; i < 100; i++) {
                        area.append("This is line number " + i + "\n");
                        Thread.sleep(500);
                    }
                }
                catch (InterruptedException e) {
                    System.err.println(e);
                }
            }

            public void stop() {
                System.out.println("Stopping applet ...");
                thread.interrupt();
                area.setText("");
            }

            public void destroy() {
                System.out.println("Destroying applet ...");
                area = null;
            }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        None.

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

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

        Release Regression From : tiger-beta2
        The above release value was the last known release where this
        bug was known to work. Since then there has been a regression.
        (Incident Review ID: 240335)
        ======================================================================

              osemenovsunw Oleg Semenov (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: