Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes Blank JOptionPane RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Blank JOptionPane RMI" Watch "Blank JOptionPane RMI" New topic
Author

Blank JOptionPane RMI

Dan Greer
Greenhorn

Joined: Jan 08, 2010
Posts: 11
I am creating an RMI project but I am running into a problem when I go to display JOptionPanes. When updating the Clients from the server, my game is supposed to display a message to every player if someone won the game but the JOptionPane just shows a blank box with a title, no message or button. I can't figure out what I am doing wrong. I am thinking that it has something to do with threading but I am not that experienced yet.

Part of the code in the Client class:


Update method in the Server class:

I hope I have explained this well enough. Thank you for your help.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Dan,
In future, while posting code, please UseCodeTags

I tried out your code and it works for me.

I get a dialog titled "Congratulations" with the message and an OK button.

Can you test with the following code and tell us what happens?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Dan Greer
Greenhorn

Joined: Jan 08, 2010
Posts: 11
Hello. I made the change to the code but I still get an empty JDialog box. Is there a way to change how I update the clients or something?

Thank you
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

What objects are Remotes? Only the server, or the clients as well?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Dan Greer
Greenhorn

Joined: Jan 08, 2010
Posts: 11
They both extend the Remote class.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

How do the pair get references to each other?
Dan Greer
Greenhorn

Joined: Jan 08, 2010
Posts: 11
The client gets a reference to the server through the registry which the server binds itself to. The client then adds itself to a collection that the game has of every client so that it can call update on all of them. It is supposed to be an implementation of the observer pattern.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Dan Greer wrote:The client gets a reference to the server through the registry which the server binds itself to.

That looks good enough.

The client then adds itself to a collection that the game has of every client

How? Show us this code, on the client side.
Dan Greer
Greenhorn

Joined: Jan 08, 2010
Posts: 11
Here is the code that the Client calls to add itself to the Server.




This is what the serve calls to update each client:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Dan Greer wrote:Here is the code that the Client calls to add itself to the Server.

So a client calls "server.addPlayer(this, someName)"? If so then that should register the client just fine.
Pawel Kedzia
Greenhorn

Joined: Apr 03, 2011
Posts: 2
Hi everyone

I have to refresh this topic because I have the same problem. I don't know why using RMI JOptionPane doesn't work. Anybody solved this problem?
Dan Greer
Greenhorn

Joined: Jan 08, 2010
Posts: 11
I was working on this over a year ago for a school project, so its hard to recall what I did but looking at the code, it looks like I ended up scrapping the JOptionPane and just displaying the message in a text box on each client. Sorry I can't be of more assistance.
Pawel Kedzia
Greenhorn

Joined: Apr 03, 2011
Posts: 2
For this moment I replaced JOptionPane by JFrame with appropriate buttons. But I am still curious why this happen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Blank JOptionPane RMI
 
Similar Threads
sending message to client
JOptionPane in AWT ?? [Similar to that]
JOptionPane halts RMI thread
Calling JOptionPane in A servlet Class
How to remove selection of initialValue in JOptionPane