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

Initial CR fails (inserts a space) in JTextArea

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1.5
    • client-libs
    • None
    • unknown
    • solaris_2.5.1

      /* Click in the JTextArea and then hit CR. The first
       * carraige return is interpreted as a space, subsequent
       * CR's seems to work. This bug is item 2 in the message
       * below.
       */


      /*

      From: Tony LaPaso <###@###.###>
      To: ###@###.###
      Subject: ---- JTextArea and JTextField ----
      Date: Thu, 13 Nov 1997 22:13:27 -0700

      Hello,

      I'm using JDK v1.1.4 with Swing v0.5.1 on Windows NT v4.0 with
      Service Pack #2.


      I wanted to mention some strange behavior of JTextField and
      JTextArea. I feel all the behaviors described below are
      anomalous. My comments apply to both classes unless otherwise
      noted. Please realize that some of my comments may simply
      reflect a lack of knowledge on my part on how to use some
      Swing capability.

      I created a simple JTextField and JTextArea in a JFrame using
      these statements (where 'f' is the JFrame):

            // the layout manager does not seem to matter...
            f.getContentPane().setLayout(new FlowLayout());
            f.getContentPane().add(new JTextArea(6, 45));
            f.getContentPane().add(new JTextField(45));



      COMMENTS
      --------

      1. The caret does not blink when in the JTextArea. I realize
      Caret.setBlinkRate() can be used to force the caret to blink but
      I feel that blinking should be the default. This is not a
      problem with JTextField.

      2. When the return key is pressed in the JTextArea, the caret
      does not move down to the next line.

      3. The standard behavior (in Windows) for Ctrl-Z is to "undo" the

      most recent operation. For example, if I paste text into a
      JTextField or JTextArea and then press Ctrl-Z, the pasted text
      *should* be removed. This does not occur. Ctrl-Z seems to have
      no effect.

      4. Shift-End should highlight the text from the current caret
      position to the end of the current line. Similarly, Shift-Home
      should highlight the text from the current caret position to the
      beginning of the current line. I believe this to be very
      standard behavior. JTextField and JTextArea do not seem to
      implement it.

      5. This may be minor but I'll mention it anyway. It would be
      nice if Ctrl-Right Arrow moved the caret to the beginning of the
      "next word" to the right. Ctrl-Left Arrow should have analogous
      behavior to the left. this is also very standard (in Windows).

      6. It would also be *really nice* if JTextArea had support for
      "word-wrap". In other words, when the caret reaches the right
      edge of the JTextArea, the word currently being typed by the
      user is automatically moved down to the next line.



      Thanks for your time. My company is producing 100% Java
      applications and we're trying to use Swing to do so.

      --
      +====================================+
      | Tony LaPaso -- ###@###.### |
      | |
      | Cyclone Software Corporation |
      | Phoenix, Arizona USA |
      +------------------------------------+
      | Be good. |
      +====================================+

      */


      /* setenv JDKHOME /home/hmuller/ws/jdk12/build/solaris
       * ${JDKHOME}/bin/javac -classpath ${JDKHOME}/classes JTextAreaKeyBindingBugs.javaxb
       * ${JDKHOME}/bin/java -classpath .:${JDKHOME}/classes JTextAreaKeyBindingBugs
       */


      /* setenv JDKHOME /usr/local/java/jdk1.1.5/solaris
       * setenv SWINGJAR /usr/local/java/swing-0.5.1/swing.jar
       * ${JDKHOME}/bin/javac -classpath ${SWINGJAR}:${JDKHOME}/lib/classes.zip JTextAreaKeyBindingBugs.java
       * ${JDKHOME}/bin/java -classpath .:${SWINGJAR}:${JDKHOME}/lib/classes.zip JTextAreaKeyBindingBugs
       */

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

      import com.sun.java.swing.*;
      import com.sun.java.swing.event.*;
      import com.sun.java.swing.text.*;
      import com.sun.java.swing.border.*;


      class JTextAreaKeyBindingBugs
      {
          static public void main (String args [])
          {
      JFrame f = new JFrame("Bug");

              f.getContentPane().setLayout(new FlowLayout());
              f.getContentPane().add(new JTextArea(6, 45));
      f.getContentPane().add(new JTextField(45));

      WindowListener l = new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
      };
      f.addWindowListener(l);
      f.pack();
      f.show();
          }
      }

            tprinzing Tim Prinzing (Inactive)
            sswingtrsunw Swingtraq Swingtraq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: