• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Illegal state exception thrown from requestFocus in JavaFX

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am attempting to create a very simple game where two squares move around and each can see the other square moving. This is a multi-player game over a TCP network using JavaFX. I am getting an illegal state exception when I call requestFocus(). This is my server:



I seem to be in over my head trying to create a networked game. Here is the client side code:



Any help will be greatly appreciated.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. Welcome to the ranch!

That's an awful lot of code.
Maybe you can point out the relevant bits? And please UseCodeTags when posting code to get the pretty formatting that makes it easier to read

>My main issue seems to be that I am unable to read in an integer from my server that determines first player and second player
Well what are you seeing? Does it do any output?
Are there any error messages?
Does it log connections successfully?

There are a couple of places where you catch and "swallow" exceptions.
At the least you should log them to record they happened. It might show you where your mistake is.
Right now it won't even tell you if something is wrong.

 
Robert Campbell
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the delayed response. In short, I am trying to send key codes to a server and send then back out to the clients.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Robert Campbell wrote:Sorry for the delayed response. In short, I am trying to send key codes to a server and send then back out to the clients.



But you originally said

My main issue seems to be that I am unable to read in an integer from my server that determines first player and second player.



Those two sentences don't seem to have anything in common except that there's a server. However I think your main problem is that you have written two hundred lines of code without testing anything on the way, and when you finally get around to running the code you have no idea to look when it doesn't work right. So I'd suggest putting that big lot of code aside for a while and writing a small piece of code whose sole purpose is to do whatever you want to do, such as reading an integer from a server. When you have that working, then try to integrate it into the original code.
 
Robert Campbell
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I move the requestFocus out of the new thread I created, I get an infinite loop and a stream corrupted exception.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic