Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6229853
Votes 0
Synopsis BasicTextAreaUI:create method are contrary to the documentation
Category java:classes_swing
Reported Against
Release Fixed
State 3-Accepted, bug
Priority: 4-Low
Related Bugs
Submit Date 16-FEB-2005
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 :
 customer  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 -
  xxxxx@xxxxx  
false
false
javax.swing.plaf.basic.BasicTextAreaUI$  xxxxx@xxxxx  
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.
  xxxxx@xxxxx   2005-2-16 12:11:16 GMT
Work Around
N/A
Evaluation
Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=13478
Posted Date : 2006-06-08 20:59:50.0
Comments
  
  Include a link with my name & email   

Submitted On 03-APR-2007
Is this bug fixed?

I reproduced the output on WinXP with the current Java SDK version - that is without Java 6u1 update.

I think Java 6u1 update fixes some Swing bugs however i am not sure if this still needs to be fixed. 


Submitted On 03-APR-2007
Here is the output from my test with the Testcase mentioned above:

Type of v: javax.swing.text.BoxView@10dd1f7
PlainView false
WrappedPlainView false
Type of v:javax.swing.plaf.basic.BasicTextAreaUI$PlainParagraph@53c015
Plain View false
WrappedPlainView false


Submitted On 03-APR-2007
SOLUTION?

Can it be that create() returns BoxView because BoxView is parent class of WrappedPlainView? The API documentation says that WrappedPlainView is directly inherited from BoxView so i assume this is a class type issue.



PLEASE NOTE: JDK6 is formerly known as Project Mustang