JDK-1253554 : TextArea component should support word-wrap mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.0,alpha,1.0.2,1.2.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.4,solaris_2.5,windows_95
  • CPU: x86,sparc
  • Submitted: 1996-06-04
  • Updated: 1997-10-23
  • Resolved: 1997-10-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.1 1.1Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
The TextArea component should support a word-wrapping attribute
so that horrizontal scrolling can be turned off and word-wrap will
automatically wrap a word when the text comes to the edge of the
TextArea.  Currently text can be added indefinitely without wrapping
and this is not always desirable.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.1 INTEGRATED IN: 1.1
14-06-2004

EVALUATION ====================================================================== Word Wrap for TextArea 961024 The Problem: There is no automatic word wrap for the TextArea class. Word wrap is considered almost an essential feature of multi-line text entry, a feature which people have come to expect of today's professional applications. Matters are made worse by the fact that in all of our native environments, word wrap is extremely easy to turn on when writing an application yourself in native code, but is impossible to turn on from Java in an AWT TextArea. In most applications with multi-line text entry, what you really want is a vertical scrollbar, and word wrap instead of a horizontal scrollbar. What we give people is scrollbars in both the vertical and horizontal direction, and no word wrap, so that the naive user ends up writing one long line scrolling off into the distance. This frustrates our users unnecessarily, and not surprisingly, we have received many requests to support Word Wrap for 1.1. We have looked into what it would take to implement this, and found that it will be quite easy to provide an elegant solution with minimal code changes on all platforms except Tiny. Related Problem: As soon as you start thinking about word wrap, you almost immediately notice that it obviates the use of the horizontal scrollbar. A naive solution would be to allow turning worwrap on and off, and remove or add the horizontal scrollbar as a side effect. This approach would be most unfortunate, since it would hinder the design of a more general system of control of the visibility for scrollbars. What is really called for is an inversion of the problem whereby we provide a general mechanism for controlling the visibility of scrollbars, and have word wrap enabled or disabled as a side effect of changing the visibility of the horizontal scrollbar. In fact, we have already done quite a bit of work for 1.1 to define the new Container class ScrollPane, which gives the AWT user control over a Scrolling window. The concept which seems most promising for reuse in TextArea scrolling is most useful for the current purpose is the notion of scrollbarDisplayPolicy, which allows the programmer to decide the circumstances in which scrollbars are displayed. Unfortunately it is not as simple as applying this directly to the TextArea class. The scrollbarDisplayPolicy controls whether scrollbars are shown always, neve, or only when they are needed, but provides no individual control over horizontal and vertical scrollbars, which is really what is required here. Supporting the 'as needed' case is really not essential, at least for a first cut, although it may be nice to have in the long run. In fact, an examination of the native implementations of TextArea and ScrollPane shows that it would be alot of extra work to implement the 'as needed' scrollbarDisplayPolicy for TextArea. Since the flexibility of allowing scrollbars 'as needed' is somewhat tangential to the problem of the lack of word wrap, and would greatly convolute the implemenatation at this time, we should adopt a design which does not require implementation of scrollbarDisplayPolicy, but does not preclude it from being added in a future release. Design: We add a new attribute, scrollbarVisibility, which gives the programmer the ability to fine-tune which scrollbars are displayed. The possible values for this attribute are: SCROLLBARS_NONE SCROLLBARS_HORIZONTAL_ONLY SCROLLBARS_VERTICAL_ONLY SCROLLBARS_BOTH The scope of this attibute's effect is narrower than that of ScrollPane's scrollbarDisplayPolicy, such that the two attributes could be defined for the same class. In that case, scrollbarDisplayPolicy tells instances of the class how to determine whether scrollbars should be displayed, and scrollbarVisibility tells them *which* scrollbars are to be displayed. For 1.1, word wrap will be turned on automatically in situations where there is no horizontal scrollbar, and turned off where there is a horizontal scrollbar present. This means that in 1.1, it will not be possible to have a TextArea which has neither scrollbars nor word wrap (author's note: I'm still waiting for a real world example of when you'd want that -- come on you guys!) For 1.1, we will provide very limited programmer access to the scrollbarVisibility attribute for TextArea. It may be set in a new TextArea constructor, and instances may be queried for the value with the method public int getScrollbarVisibility() This design provides a solution which allows programmers to enable word wrap in AWT TextAreas with minimal API additions, while providing backwards compatibility. It solves a real problem which our users have and complain about; one which is extremely difficult for them to work around and which hinders them from using the AWT to make applications with the kind of sophisticated, professional GUIs that users expect in this day and age. The solution proposed requires minor changes to 1.1 source code. And not to be overlooked, it provides a design which is consistent and complementary to that of ScrollPane such that the two designs can be dovetailed in future releases according to user feeback and demand.
11-06-2004

PUBLIC COMMENTS A word-wrap attribute needs to be added to the TextArea.
10-06-2004