Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing focus w/o using mouse  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two JFrames (or something like that). Say, frame A and
Frame B. When I click on something in Frame A, I want Frame B
to get focus and come to the foreground.
Any ideas? I have tried to create a MouseEvent using MOUSE_PRESSED, but I can't find a way to fire or dispatch it!
Any other ideas?
leslie
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leslie,
You need a reference to each frame to do anything. If you have a reference to the other frame you could try and request focus. I am not really sure about the API. I would start looking in the Component API.
I am not sure how to do it if you don't have a reference to the other frame. Even to fire an event you need an object to fire the event to ...
Regards,
Manfred.
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add a MouseListener to the component in Frame A, then call requestFocus() on Frame B.

However, as Manfred said, you will need a reference to Frame B in order to do this.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!