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

word wrap is not intelligent enough

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs



      Name: rmT116609 Date: 09/27/2000


      java version "1.3.0"

      JTextArea word wrapping in 1.3 is still non-optimal. Sentences are wrapped by
      breaking words in two parts, rather than preserving words and breaking on
      whitespace. In my example program, and on my Win98 box, the word fox is broken
      by leaving the 'f' on the top line and putting the 'ox' on the second line.
      Sensible word wrap would, presumably, preserve the word "fox" and break on the
      whitespace preceding the word.

      import javax.swing.*;
      import java.awt.Dimension;
      import java.awt.event.*;
      public class wordWrap {
        static JTextArea jtf;
        static JFrame frame;

        public static void main(String[] args) {
          frame=new JFrame("Word Wrap");
          Box box=Box.createHorizontalBox();
          frame.setContentPane(box);
          jtf=new JTextArea();
          jtf.setLineWrap(true);
          jtf.setPreferredSize(new Dimension(100, 35));
          jtf.setMaximumSize(jtf.getPreferredSize());
          jtf.setMinimumSize(jtf.getPreferredSize());
          box.add(jtf);
          jtf.setText("The quick brown fox jumped over the lazy dog!");
          frame.pack();
          frame.show();
          frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
              System.exit(0);
            }
            });
        }
      }
      (Review ID: 110089)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: