• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to make the only the Child form enabled?

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application is with JInterrnalFrames and JDesktopPane(Virtual desktop).
When I open up a child form, I would like to make parent form disabled.
I tried getting all InternalFrames in virtualdesktop and tried disabling it.I could get all internalframes but I could not disable them.
Any help?
Thanks
Sri
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
what do you mean with disabling a JInternalFrame.
Do you mean setEnabled(false)? I think, this can't work, because the components inside the frame are not disabled. You could try to work with the GlassPane. If you set the glasspane of your parent to visible, then no mouseclick would reach a component behind and the glasspane is the most top component. If your childframe is closed, then you have to set the glasspane to invisible.
Hope this helps a bit

Rene
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene
Currently I am opening my child Internal frame as below:

But , when my child internal frame is open, still my parent form is enabled and editable.
Thanks
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you are right, and I don't know why.
So you have to make a workaround. Put all your components in a Vector and implement a setAllComponentsEnabled(boolean enable) method.
This is ugly, but it will work. Maybe someone else knows, why the glasspane doesn't work.
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to open the JInternal Frame as Modal. same as JDialog or JOptionPane
Thanks
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, not really. But it is possible, to simulate this. I did this two years ago.
Here is the code:

This is not modal, but it is alway on top.
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene
Thanks you very much for the code
I tried opening AlwaysOnTopInternalFrame class from my Partent Internal Frame and as desired I could not edit my Parent Form.
1) But when I clicked on the Parent form, AlwaysOnTopInternalFrame goes behind the Parent form
2) And When I close the AlwaysOnTopInternalFrame, my parent form is still non-editable.
Do I have to do anything different?
Thanks for your time Rene
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found it. My AlwaysOnTop.. worked, but the toFront() method of it was called earlier than the toFront method of the parent frame.
So I added following code to the parent frame:

In other words, I added a InternalFrameListener and in the implementation of it I ask if we have a child frame (which must be a member). If no then we have nothing to do and if yes, we send it to back.
But anyway, I think it will not solve your problem, because the parent frame is editable.
So I think you have to implement a recursive setComponentEnabled method for your internal frames. This you could merge with the AlwaysOnTopInternalFrame.

 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene
It looks like implementing setEnabledComponents() is the only option to disable and enable the Parent and Child Internalfrmaes though it does not seem sleek.
Now I am calling setEnabledComponents() right after my parent form open the child internalframe. But When I close my child form, how can I enable my parent form components.
Passing the parent form reference to the child form when the child form is open so that when the child form is closed I can use the parent for reference to call setEnabledComponents() method.
Thanks
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, this is easy. As you already have a InternalFrameListener in your parent for your child, it is easy for you to listen for the internalFrameClosing event. There you can call the method setComponentEnabled(true).
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene
Thanks for your help.
I implemented the internalFrameClosing() on the Parent Frame and calling setComponentEnabled(true). But when my child form is closed, how the internalFrameClosing event on the Parent form will be fired. This event will be fired only when the parent form is closed. Am I missing something?
Sri
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe my last post sounds a bit confusing. I mean, that your parent form has to implement a InternalFrameListener for the child form. Only then your parent is able to know when your child form is closing.

If this was a homework for you, then I shoud get your mark 1.
[ June 26, 2002: Message edited by: Rene Liebmann ]
 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rene. It worked
 
reply
    Bookmark Topic Watch Topic
  • New Topic