Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal state exception thrown from requestFocus in JavaFX

 
Robert Campbell
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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.
 
Stefan Evans
Bartender
Posts: 1807
10
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Paul Clapham
Sheriff
Posts: 21567
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic