Hi,
I'm a total newbie to Java (forced into it via a master's class, actually,
but enjoying it!). I've scoured my Java books and the web for what I'm sure
is very simple stuff but am coming up blank.
Basic premise: build an applet that has a JTextArea in which to display some
simple lines of text as the applet runs. Using JBuilder Foundation I'm able
to build the GUI in the init() method and am hacking my way through learning
what all the auto-generated code means. As a Delphi guy, it's slowly making
sense.
My applet has multiple custom classes, each in their own .java file, that
need to be able to write to the JTextArea. But I can't for the life of me
figure out how to reference that component or write to it in classes other
than the main class that extends applet.
In Delphi I'd simply add the main class that contains the JTextArea to the
'uses' clause of other classes, but I don't know the equivalent
functionality in java. Can anyone tell me the basic concept, or where in
the Sun or JBuilder docs to find it? I'm stumped.
Thanks,
Chris
Andrew Thompson - 16 Dec 2004 03:11 GMT
> I'm a total newbie ...
[1]
>..to Java (forced into it via a master's class, actually,
> but enjoying it!). I've scoured my Java books and the web for what I'm sure
> is very simple stuff but am coming up blank.
>
> Basic premise: build an applet
Why an applet? [1] That is not a good place to start
if you are new to Java
<http://www.physci.org/codes/javafaq.jsp#appfirst>
>..that has a JTextArea ..
Why a JTextArea specifically? Has it got something that
an Applet or HTML TextArea does not?
What does your applet (supposed to) do?
>..in which to display some
> simple lines of text as the applet runs. Using JBuilder Foundation
Oh-oh. There's trouble.
<http://www.xdweb.net/~dibblego/java/faq/answers.html#Q34>
You need to learn how to code Java before you let an advanced
IDE like JBuilder mess it up with it's ..what do they call it..
XYLayout, or AbsoluteLayout?
>...I'm able
> to build the GUI in the init() method and am hacking my way through learning
> what all the auto-generated code means.
Toss it and add your text area (with scrollpane if necessary)
to the CENTER of a BorderLayout.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
klynn47@comcast.net - 16 Dec 2004 04:01 GMT
Do you have a reference to the different classes as instance variables
in your applet?
Lee Weiner - 16 Dec 2004 05:34 GMT
>Basic premise: build an applet that has a JTextArea in which to display some
>simple lines of text as the applet runs. Using JBuilder Foundation I'm able
[quoted text clipped - 6 lines]
>figure out how to reference that component or write to it in classes other
>than the main class that extends applet.
I assume you're creating instances of your "custom classes" inside the applet
class. If so, pass a reference to the JTextArea in the constructors of those
classes.
Lee Weiner
lee AT leeweiner DOT org