Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Interface constructor

Posted on 2004-08-10
3
Medium Priority
?
432 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 100 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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 …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

824 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