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

REGRESSION: JTextArea doesn't wrap in 1.3 but does in 1.2.2

XMLWordPrintable

    • beta
    • generic
    • generic



      Name: rmT116609 Date: 12/21/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      My application uses the following class to create a component that looks like a
      label but has wrapping lines. This works fine on JDK 1.2.2, but does not wrap
      the lines on JDK 1.3. The lines are one single line that gets clipped at the
      end of the panel.

      // WrapLabelTest.java

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class WrapLabelTest extends JFrame
      {
          String t = "This is a test of the emergency broadcast system, this is only a test. If this would have been an actual emergency, you would have been instructed where to tune for more indepth information.";
          
          public WrapLabelTest()
          {
              super( "Wrap Label Test..." );
              
              addWindowListener( new WindowAdapter()
              {
                  public void windowClosing( WindowEvent e )
                  {
                      System.exit( 0 );
                  }
              } );
              
              getContentPane().setLayout( new BorderLayout() );
              getContentPane().add( new WrapLabel( t ), BorderLayout.CENTER );

              // Show the window
              pack();
              setSize( 400, 400 );
              show();
          }
          
          /**
           * main to run as application
           */
          public static void main( String[] args )
          {
              new WrapLabelTest();
          }
      }

      // WrapLabel.java

      import javax.swing.*;
      public class WrapLabel extends JTextArea
      {
          public WrapLabel( String s )
          {
              super( s );
          }

          public void updateUI()
          {
              super.updateUI();
              setLineWrap( true );
              setWrapStyleWord( true );
              setHighlighter( null );
              setEditable( false );
              LookAndFeel.installBorder( this, "Label.border" );
              LookAndFeel.installColorsAndFont( this, "Label.background", "Label.foreground", "Label.font" );
          }
          
          public boolean isFocusTraversable()
          {
              return false;
          }
      }
      (Review ID: 114172)
      ======================================================================

            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: