Article View: borland.public.jbuilder.java.swing
Article #1475Re: jTextArea component - help an old newbee!!!
From: Algis Kabaila
Date: Mon, 01 Dec 2003 18:29
Date: Mon, 01 Dec 2003 18:29
72 lines
3947 bytes
3947 bytes
Paul Furbacher wrote: > Any model for a JTextArea should implement Document. > The default model for JTextArea is > javax.swing.text.PlainDocument. Yes, in the SimpleTextEditor tutorial example the jTextArea1 is related (line 82 of code) to document1, which is of the type Document (line 61 of code). The document1 is also used to "listen" to text changes (line 118) and also appears in lines 399, 406 etc. Strange, I did the tutorial twice, but do not remember any instructions to create or use document1 of type Document. Is its creation one bit of magic performed by JBuilder? > Since it looks as though you are going to use > a very simple document structure, you might > want to take advantage of the default document's > "getParagraphElement(int pos)" method. The > default model is line-based, so "pos" is the > line number. Yes, my handling of the input is very simple indeed. And "getParagraphElement(int pos)" is the very method that corresponds to the Delphi text components method of reading lines. But how do I implement it? JArea1 component does not know about it. "document1" does not know about it either - compiler tells me that. So how can I use it? Most of the methods that I can access in document1 relate to individual characters, and not lines of text. It is the lines of text that I would like to acess as strings. I would then extract the numeric data from it, which, after all, constitutes 99% of the data. > Using this method of getting each line obviates > the need to calculate offsets, etc., and may > make you code more readable. Absolutely yes! But how to do it? > On a side issue: > >> Of course, it is nice to start with some of the work >> already done for you - I see no better way than to use an >> existing sample editor! I have gone through the tutorial >> to become familiar with it and to produce a "new" code, >> being conscious of the copyrignt notice on the example. > > Yes, and no. The editor may in fact be far too > complicated, with features which get in the way, > rather than help. I often use the samples as springboards > for testing ideas, but just as often, I'll start with > a blank slate. The latter approach lets me concentrate > on just the issues related to a specific component. > Reducing the number of side effects which a complex > example may introduce can potentially save time. > But there's no "this way is the best way" in this > matter. Actually, I think that the "Simple Editor" is of about the right complexity. In fact, I would add a facility of changing the fonts - important for sight impaired and older users. Of course, from a programmers view point, the input-output separation seems desirable and logical. From a user's viewpoint, I think the opposite is true. Thanks again, Al. -- Al. Kabaila
Technical Details
Message-ID:
<bqet3f$21fqeh$1@ID-216608.news.uni-berlin.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!ta-1-28.tip.net.AU!not-for-mailReferences:
<bq3lia$1tiqfa$1@ID-216608.news.uni-berlin.de> <bq3n98$1ublqa$1@ID-216608.news.uni-berlin.de> <3fc78900$1@newsgroups.borland.com> <bqbe3a$1pq2v0$1@ID-216608.news.uni-berlin.de> <3fca3399$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,663e7dcc14de267d X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-12-01 00:11:29 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!ta-1-28.tip.net.AU!not-for-mail From: Algis Kabaila <akabaila@pcug.org.au> Newsgroups: borland.public.jbuilder.java.swing Subject: Re: jTextArea component - help an old newbee!!! Date: Mon, 01 Dec 2003 18:29:07 +0000 Organization: PC Users Group Lines: 72 Message-ID: <bqet3f$21fqeh$1@ID-216608.news.uni-berlin.de> References: <bq3lia$1tiqfa$1@ID-216608.news.uni-berlin.de> <bq3n98$1ublqa$1@ID-216608.news.uni-berlin.de> <3fc78900$1@newsgroups.borland.com> <bqbe3a$1pq2v0$1@ID-216608.news.uni-berlin.de> <3fca3399$1@newsgroups.borland.com> Reply-To: akabaila@pcug.org.au NNTP-Posting-Host: ta-1-28.tip.net.au (203.11.71.28) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 1070266287 68676049 203.11.71.28 ([216608]) User-Agent: KNode/0.7.2