wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes focusable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "focusable" Watch "focusable" New topic


Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
alright, i have ship objects, and the ship class extends JPanel..

now when i first enter my GUI, I can move the ships around on the

board, but as soon as i click in the chatTextField, the ships go un-focusable, and i cant move them any more..

why is this?

also, is there any method like JPanel.contains(point(x,y)); ?


You down with OOP? Yeah you know me!
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
There's a Swing forum here at the JavaRanch where this topic would be more at home. Regardless, there's a few things that are odd. First of all, a JPanel is a container and isn't generally a focus owner to begin with. The decision to have "Ship" extend JPanel seems dubious at best. You're also going to need to post some code to show us what you're doing and what the problem is before we can help further. I can't divine why you can't move your ship after clicking on a text field but I can tell it almost certainly has little to do with it being "unfocusable".

Look up Component.contains(int,int) for the answer to your other question. I'd link it but the forum software won't let me.
marc weber

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Ken Blair:
There's a Swing forum here at the JavaRanch where this topic would be more at home...

Indeed. Please continue this discussion there.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link: http://aspose.com/file-tools
subject: focusable
It's not a secret anymore!