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

BasicTextAreaUI:create method are contrary to the documentation

    Details

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600],
      Linux pbtmrte001 2.4.21-9.ELsmp #1 SMP Thu Jan 8 17:08:56 EST 2004 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      API specification says about create of BasicTextAreaUI :
      "Returns a WrappedPlainView or PlainView". But in some cases this method returns BoxView and other views.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run (see "source code for an executable test case"):
      javac CreateTest.java
      java CreateTest


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      View is instance of PlainView or WrappedPainView according to documentation.
      ACTUAL -
      javax.swing.text.BoxView@9971ad
      false
      false
      javax.swing.plaf.basic.BasicTextAreaUI$PlainParagraph@1f630dc
      false
      false


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.lang.reflect.InvocationTargetException;

      import javax.swing.JFrame;
      import javax.swing.JTextArea;
      import javax.swing.SwingUtilities;
      import javax.swing.plaf.basic.BasicTextUI;
      import javax.swing.text.Element;
      import javax.swing.text.PlainView;
      import javax.swing.text.View;
      import javax.swing.text.WrappedPlainView;

      public class CreateTest extends JFrame {
          static JTextArea jta;
          public CreateTest(){
              super();
              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });
              
              jta = new JTextArea("\u05dc");
              getContentPane().add(jta);
              setSize(200,200);
              setVisible(true);
          }
          public static void main(String[] args) {
              new CreateTest();
              try {
              SwingUtilities.invokeAndWait(new Runnable() {
                  public void run(){
                      Element elem = CreateTest.jta.getDocument().
                          getDefaultRootElement();
                      BasicTextUI ui = (BasicTextUI)jta.getUI();
                      View v = ui.create(elem);
                      System.out.println(v);
                      System.out.println(v instanceof PlainView);
                      System.out.println(v instanceof WrappedPlainView);
                      elem = elem.getElement(0);
                      v = ui.create(elem);
                      System.out.println(v);
                      System.out.println(v instanceof PlainView);
                      System.out.println(v instanceof WrappedPlainView);
                      
                  }
              });
              } catch (InvocationTargetException e){
              } catch (InterruptedException e){}
                 
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Improve documentaion.
      ###@###.### 2005-2-16 12:11:16 GMT

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jssunw Jitender S (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: