?
Solved

java.awt.TextArea

Posted on 1997-08-15
6
Medium Priority
?
277 Views
Last Modified: 2008-02-26
I am using a java.awt.TextArea and it will not seem to give me the Horizontal Scroll Bar when I appendText() to the TextArea that goes beyond the width of the TextArea.  Does anyone know why or how this could happen?  If so, how can I correct this?  Also, has anyone done anything before which will make the TextArea wrappable so that if text is appended to the textarea that is wider than its specified width, it will just automatically wrap to the next line?  If so, I would appreciate some help.  Thanks.
0
Comment
Question by:cadillac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:russgold
ID: 1225100
What VM are you using?  What version of Java?  appendText() works just fine for me in JDK 1.02.


0
 

Author Comment

by:cadillac
ID: 1225101
I am using it in Netscape Navigator Gold.

I believe you misunderstood the question...appendText() works fine.  I just used appendText as an example of when I add text to the text area.  If I add enough text where the string is longer than the textarea's width, it should open up the horizontal scrollbar, but it never does with mine.  I am not sure why.  Do you know how to make it so the textarea is just wrappable?
0
 
LVL 4

Accepted Solution

by:
russgold earned 200 total points
ID: 1225102
The behaviour you are seeing is incorrect, and due to a bug in Netscape 3.0's JVM. This is fixed in version 4 (Communicator)

JDK 1.1 adds a new constructor to TextArea which allows you to specify whether and which scrollbars are to be enabled. If you disable horizontal scrollbars, text will be word-wrapped automatically.

This behavior is unfortunately unavailable in JDK 1.02 (which Navigator Gold 3.0 uses).
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:cadillac
ID: 1225103
You don't know how to make the textArea wrappable using JDK 1.02 do you?  I am looking for a workaround for now...
0
 
LVL 4

Expert Comment

by:russgold
ID: 1225104
A workaround?  Well, there is a way, but it's kind of painful:

1. Subclass TextArea as a WordWrappingTextArea:

2. Add a private method which will take a raw string and word-wrap it by inserting returns ('\n') at the appropriate points.

3. Add another private method to remove the returns from such a string.

4. When *any* change is made to the text, remove any previous returns and insert new ones at the appropriate point (this means overriding handleEvent and catching each keystroke, as well as overriding appendText, insertText, replaceText, and setText).

5. Also, override getSelectedStart, getSelectedEnd, and select() to  accomodate the extraneous returns.

6. When a client asks for the current text (getText and getSelectedText), remove the extraneous keystrokes.

Once you have this class, you will have full control over word-wrapping, but your changes will be incompatible with JDK 1.1.
0
 

Author Comment

by:cadillac
ID: 1225105
Thanks

0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question