Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Blank JOptionPane RMI

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They both extend the Remote class.
 
Rob Spoor
Sheriff
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22510
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For this moment I replaced JOptionPane by JFrame with appropriate buttons. But I am still curious why this happen.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic