Article View: borland.public.jbuilder.java.swing
Article #1458jTextArea component - help an old newbee!!!
From: Algis Kabaila
Date: Thu, 27 Nov 2003 01:21
Date: Thu, 27 Nov 2003 01:21
46 lines
2738 bytes
2738 bytes
Hi,
Though I am 78, I am a newbee in JBuilder, Swing components, Java and C, so
I need some very basic help.
I want to port some of my old Delphi (vers 5) programs to public domain,
incl. Linux. One way of doing it is to do a re-write in Java and that is
what I am attempting to do.
To the "SimpleTextEditor" example of JBuilder Personal, I added a button and
the following code to see how JTextArea component works. My Delphi program
reads the data from the text component, processes it and then attaches the
results at the end of the text component. This ensures that the data and the
corresponding output are at the same place.
To the "SimpleTextEditor" example of JBuilder Personal, I added a button and
the following code to see how JTextArea component works. I have not
attempted to do any processing of it - just an echo check of data. (I don't
know how to handle exceptions in Java, so I fudged the code for the catch
clause).
// Al added this method to see how the jTextArea1 component works.
void jBTest_actionPerformed(ActionEvent e) {
file://Read text from the JTextArea1 and append at the end of it.
int len = 0;
int line = 0;
int lineCount = jTextArea1.getLineCount();
jTextArea1.append("\n\n ---------------------------------------------\n"
);
jTextArea1.append("Appended text\n");
for (line=0;line<lineCount;line++) {
try{
len = jTextArea1.getLineEndOffset(line) -
jTextArea1.getLineStartOffset(line) + 1;
jTextArea1.append(jTextArea1.getText(line,len));
}
catch(Exception g ){
jTextArea1.append("\n Bad location exception occurred");
}
}
}
The output is a mixture of the first and the second line of entered text. I
find it weird and don't see what is going on. Any suggestions would be
greatly appreciated (even if you just tell me off...).
Thanks, Al.
Technical Details
Message-ID:
<bq3lia$1tiqfa$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-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,663e7dcc14de267d,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-11-26 17:55:26 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: jTextArea component - help an old newbee!!! Date: Thu, 27 Nov 2003 12:21:41 +1100 Lines: 48 Message-ID: <bq3lia$1tiqfa$1@ID-216608.news.uni-berlin.de> NNTP-Posting-Host: ta-1-28.tip.net.au (203.11.71.28) X-Trace: news.uni-berlin.de 1069898124 64580074 203.11.71.28 ([216608]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200