dcsimg
How to detect whether the jinternalframe in open or not?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Billy_Tong
Posted On:   Thursday, April 3, 2003 12:57 AM

I want to detect the jinternalframe whether it is open or not, so the user will not able to open a second same jinternalframe when pressing the menubutton/toolbar button second time.


Is there anyway other than the button enable/disable trick, which i don't like. :(


Thanks again. I am a newbie in Java. Few weeks exp. :-)

Re: How to detect whether the jinternalframe in open or not?

Posted By:   Bahman_Barzideh  
Posted On:   Thursday, April 3, 2003 11:03 AM

If I read your question correctly, you want to have some logic that is
executed when a user clicks on a tool bar button or selects a menu
item in your app (Since you don't mention how your application is organized, I will assume you are using a JDesktopPane in what follows). You want this logic to check
and see if there is already a specific JInternalFrame visible,
and create such a JInternalFrame only if one does not exist.
If this is correct, I am not sure what the problem is. You can get a list
of all JInternalFrame's associated with a JDesktopPane by calling getAllFrames () or getAllFramesInLayer () methods of JDesktopPane. You will, of course, need your own scheme of determining if
a given JInternalFrame is of the type you are after. You can
also determine if a JInternalFrame is visible by calling its
isVisible () method.



I would suggest you take a look at Sun's tutorial on JInternalFrames on their web site.




One thing I don't undrestand is your statement about disabling menu items and toolbar buttons. I am not sure why you dislike this approach or
for that matter what you mean by it. What I can tell you for certain is
that a well developed GUI (no matter what language it is developed in)
should enable/disable menu items and tool bar buttons (as needed) when events are detected. Your code should have the logic you are describing in addition to enabling/disabling the buttons not in lieu of it.




Hope this is of some help to you!
About | Sitemap | Contact