Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

(RMI) How to let a remote object display itself on the client application?

Thread view: 
Mike - 28 Jul 2006 16:05 GMT
Hello to all.

I'm quite new to RMI and I have a theoretical question on how a
specific problem is usually solved.
My need is to create a client application not only able to work with
remote objects (that implement a specific interface) but also to
display them locally on the screen.
What I want is to have the possibility to add new classes of object on
the server (impementing the same interface as above) and have the
client able to display them too without changing the client. The client
will then receive the objects from a Factory that will return back the
object of the proper type.

My idea then, is that the object should be able to display itself, so
that the client application would only have to call something like
'print(JPanel)' on the remote object.

But how does this work? Can I pass to the server a JPanel as argument?
I don't think this will work.

How is this problem solved? Is there a pattern for this kind of
situation?

Thank you.
Michele
Thomas Hawtin - 28 Jul 2006 11:59 GMT
> I'm quite new to RMI and I have a theoretical question on how a
> specific problem is usually solved.
[quoted text clipped - 13 lines]
> But how does this work? Can I pass to the server a JPanel as argument?
> I don't think this will work.

If you pass a JPanel over RMI, it'll get copied. If you paint on
the copy, the original will not be updated.

Probably the easiest solution is to paint on an image, and serialise
that. Alternatively, you could create an implementation of Graphics that
uses RMI to paint onto a client Graphics object.

Alternatively, you could dynamically load classes onto the client, using
URLClassLoader.newInstance.

http://download.java.net/jdk6/docs/api/java/net/URLClassLoader.html#newInstance(
java.net.URL
[])

Tom Hawtin


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.