Solved

How to create own events in Java?

Posted on 1998-08-13
5
181 Views
Last Modified: 2008-02-01
How I can create my own events in Java? So that I can use them with HandleEvent?
0
Comment
Question by:Hugi
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:mjenkins
ID: 1232584
If you really mean to handle the events using Component.handleEvent you just need to subclass the java.awt.Event class. Then call postEvent( event ) for the target component. This only applies to JDK 1.0.2, however.

If you want to use JDK 1.1+ then you need to subclass java.awt.AWTEvent and call Toolkit.getEventQueue().postEvent(event)


0
 

Author Comment

by:Hugi
ID: 1232585
I don't know if you did understood my question...
What I want to do is, to start an application and send an event which I can receive by another application.

0
 
LVL 3

Expert Comment

by:mjenkins
ID: 1232586
Do you mean in two separate JVM's? That would mean some sort of IPC (inter-process communication). The best thing to do would be to open a socket between the two processes and pass your events as serialized objects.
0
 

Author Comment

by:Hugi
ID: 1232587
And how can I do that?
I have found the following, but I want to communicate between two Processes on the same machine:
Socket connection = new Socket(hostname, portnum)


0
 
LVL 3

Accepted Solution

by:
mjenkins earned 100 total points
ID: 1232588
hostname is "localhost" for the local machine. Always. You decide on a port number you would like to use. Any port number over 1000 is okay. Many people try ports in the 10000 - 11000 range.

So the call would be:

Socket connection = new Socket( "localhost", 10100 );

The server and client use the same port number.

OK?
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 85
spring jars download 1 27
eclipse buid path vs tomcat lib path 10 23
mysql jsp example issue 32 33
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 about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

770 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