Solved

java.awt.TextArea

Posted on 1997-08-15
6
272 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
  • 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 50 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

810 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