?
Solved

Event Driven in Java???

Posted on 1997-11-24
5
Medium Priority
?
455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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