Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Interface constructor

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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…
Suggested Courses

715 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