Solved

Event Driven in Java???

Posted on 1997-11-24
5
444 Views
Last Modified: 2012-06-21
Hi, there:
      It seems like Java has delegation Model for AWT event.  Do you know if this model is fit for any event?  I want to write an event-driven application in Java in which not only is driven by AWT event but also driven by any event like when some data higher than a threshhold, etc. Is that possible to use that model?  If so, how to use it?  Thanks a lot.

Gang Feng
0
Comment
Question by:feng042497
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:jpk041897
ID: 1231144
Using Introspection you can certanly create your own listeners and events and associate them to given threshholds.

Could you be a bit more clear about what kind of events you wish to monitor?

Most OS events (like timers, interrupts, etc) will have to be handled by native methods via JNI. On the other hand, you can handle most data and AWT "action" events via introspection and other techniques.

With a better idea of exactly what you wish to watch for we could give you a better answer.
0
 
LVL 1

Accepted Solution

by:
fadl earned 50 total points
ID: 1231145
The answer is Yes.
You can do both. Create your own events extending standard
AWT events and then to use them.
      (I wrote TextArea replacement and I have two
      more events such as CaretMovedEvent etc and
      my own TextAWTMutlicaster - it is then used
      via add/removeXXXListener as usually)
You can create your own events/listeners interfaces and
a kind of dispatching mechanism too. (See sources to
AWT events and AWTMulticaster as a starting point -
it's not so difficult as it might seem to)

If this is not enough, please be more specific about nature
of your task.
HTH
Michal
fadl@corpus.cz


0
 

Author Comment

by:feng042497
ID: 1231146
Hi, fadl:
      Thank you for answering this question!  I got some idea from your explaination.  But I didn't totally understand.  What kind of dispatching mechanism are you using in your program?  From the book, dispatchEvent(AWTEvent e) seems like only can dispatch event to its subcomponent.  Do you mind showing me your program?  Thanks a lot.

Gang Feng
0
 
LVL 1

Expert Comment

by:fadl
ID: 1231147
I needed to create a couple of new events in my Text
component (TextArea replacement) e.g. CaretMovedEvent
etc
To handle those new events one must implement dispatching
algorithm such as the one in AWTMulticaster class (in AWT)
I wrote my own TextAWTMutlicaster object that handles
my new events.
Generally it is not necessary to do things like this.
You can e.g. store your listeners in Vector {:) - it
works too.

Send me your e-mail address and I will send you
zipped sources to see it in action. You will understand
soon how to do it.

Michal
fadl@corpus.cz
0
 

Author Comment

by:feng042497
ID: 1231148
Hi, Michal:
      Have you received the mail I sent you?  I haven't received the reply?  So I think maybe you didn't get it.  My email address is g0f4653@cs.tamu.edu.  Have a good one!

Gang Feng
0

Featured Post

How our DevOps Team Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Options in Zimbra Server 2 55
MySQL  on Tomcat 8 48
check java version using powershell 13 96
hibernate example for saving data 19 44
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

825 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