T
Tobi Krausl
Hi there!
In my Java-program there are among others two classes:
class Java_GUI: This class "builds" the GUI (JFrame) and contains all
necessary components (Lists, Buttons…).
class MyEventHandler: This class is intended to handle all events
occuring in "Java_GUI". Additionally it will be necessary to update
some controls in "Java_GUI" depending on the events. It could be for
example necessary to change the items of a list declared in
"Java_GUI".
My plan is as follwos:
In the constructor of Java_GUI I reference a MyEventHandler-Object. So
far it's fine.
But how can I directly access the public attributes (components) in
"Java_GUI" from inside a MyEventHandler-class? I don't want to write
special public-methods in "Java_GUI" which provide the functionality
to update private attributes (components).
How could I solve my problem in a smart way? Corresponding to MVC I
would have to create something like a "Controller", right? Would
implementing "Observer" help in some way and if yes, how?
Thank you, Tobi
In my Java-program there are among others two classes:
class Java_GUI: This class "builds" the GUI (JFrame) and contains all
necessary components (Lists, Buttons…).
class MyEventHandler: This class is intended to handle all events
occuring in "Java_GUI". Additionally it will be necessary to update
some controls in "Java_GUI" depending on the events. It could be for
example necessary to change the items of a list declared in
"Java_GUI".
My plan is as follwos:
In the constructor of Java_GUI I reference a MyEventHandler-Object. So
far it's fine.
But how can I directly access the public attributes (components) in
"Java_GUI" from inside a MyEventHandler-class? I don't want to write
special public-methods in "Java_GUI" which provide the functionality
to update private attributes (components).
How could I solve my problem in a smart way? Corresponding to MVC I
would have to create something like a "Controller", right? Would
implementing "Observer" help in some way and if yes, how?
Thank you, Tobi