Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting focus of a JInternalFrame

 
Ela Jarecka
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a desktop pane to which I am adding two "types" of JInternalFrames:
- type 1 are frames that are actually closed when a user closes them ( default close operation is DISPOSE )
- type 2 just get hidden ( setVisible(false), default close operation is HIDE ).

When I have only type 1 frames open and close any of them, another one automatically gains focus.
When I have a mix of type 1 and type 2 frames and close a type 1 frame, another one automatically gains focus ( regardless whether it is of type 1 or type 2 ).
But..
when I have a mix of type 1 and type 2 frames and close a type 2 frame, none of the other frames gains focus.

Could anyone tell me why it is so? I need the functionality because depending on which frame is activated, different menu and different buttons have to be visible.
I add an InternalFrameListener to the newly created frames and overwrite the internalFrameActivated method - it all works perfectly, just in the last case I can see
that the type 2 frame gets deactivated, but none of the other frames gets activated in turn.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
apparently your type of application is not common,
how about you post a working example (of it not working correctly)
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can only think that the answer lies in the default close operation. When it is set to HIDE, it retains the focus even though it is closed. That's my guess.

So there should be a way to add some code somewhere to deal with this situation.

edit: ok this from the API for JInternalFrame...

...Before performing the specified close operation, the internal frame fires an INTERNAL_FRAME_CLOSING event.

so presumable you can have some kind of event handler based on this to do what needs to be done to make sure focus gets handled appropriately.

Anyways, I have never dealt with this kind of stuff, but it all seems logical. Hope it helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!