Solved

Interface constructor

Posted on 2004-08-10
3
405 Views
Last Modified: 2010-05-18
If I have:

-----------------------
ClientCallbacks.java
-----------------------
public interface ClientCallbacks extends java.rmi.Remote
{
    public void receiveMessage(String msg) throws java.rmi.RemoteException;
}

----------------------
ChatImpl.java
---------------------
    public void connect(ClientCallbacks cl) throws java.rmi.RemoteException
     {
           
     }

---------------------
Client.java
---------------------

ClientCallbacks callbacks;  
Connect.addActionListener(new ActionListener()
{
      public void actionPerformed(ActionEvent e)
        {
           // Complete to add action for connect.
       }
 }
);


As you can see, the connect.addActionListener wants to call the method Connect() in ChatImpl.java. How can I code that?? Would this work?

         Chat cs = new ChatImpl();
         cs.connect(callbacks);

??
0
Comment
Question by:jtcy
3 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 11770469
jtcy - How can we know whether it would work? Why don't you try it? If it is not working then - describe what is actually happenaing.
0
 
LVL 6

Expert Comment

by:valipotor
ID: 11770730
>> Connect.addActionListener(new ActionListener()
>> {
>>      public void actionPerformed(ActionEvent e)
>>        {
>>           // Complete to add action for connect.
>>       }
>>  }
>> );

Define Connect.
0
 
LVL 6

Accepted Solution

by:
expertmb earned 50 total points
ID: 11771001
>>Chat cs = new ChatImpl();
     >>    cs.connect(callbacks);

this works if

//Chat.java

interface Chat{
  public void connect(ClientCallbacks cl) throws java.rmi.RemoteException;
}

ChatImpl implements Chat{

    public void connect(ClientCallbacks cl) throws java.rmi.RemoteException
     {
          //do something
     }

}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

808 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