• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Blank JOptionPane RMI

 
Dan Greer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11064
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Dan Greer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What objects are Remotes? Only the server, or the clients as well?
 
Dan Greer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They both extend the Remote class.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do the pair get references to each other?
 
Dan Greer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this moment I replaced JOptionPane by JFrame with appropriate buttons. But I am still curious why this happen.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic