Modal Dialog box and Request focus
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sumana_Reddy
Posted On:   Friday, July 26, 2002 06:41 AM

Thank you Prasanna. I dont need resize functionality.So your suggestion will work for me. I am stuck with an other problem.If you have come across such a thing can you share your experience. I have a modal dialog box.When ever I make the dialog box visible I need to request the focus for a particular button. below is the description of how I tried to achieve the functionality I can request the focus by calling requestFocus method.We should request the focus only when the component is visible i.e only after i make the dialog box visible.But when a modal dialog box is visible it blocks the applicat   More>>

Thank you Prasanna.


I dont need resize functionality.So your suggestion
will work for me.


I am stuck with an other problem.If you have come
across such a thing can you share your experience.


I have a modal dialog box.When ever I make the dialog
box visible I need to request the focus for a
particular button.



below is the description of how I tried to achieve the
functionality



I can request the focus by calling requestFocus
method.We should request the focus only when the
component is visible i.e only after i make the dialog
box visible.But when a modal dialog box is visible it
blocks the application and the requestFoucs method is
not executed as long as the dialog is visible.



So in order to solve this problem I decided not to make
my dialog modal during creation time.When I make my
dialog visible, First i will request the focus and then
make the dialog modal.But once the dialog is visible
the modal concept is not working.thoght the setModal()
is executed and the dialog.isModal() returns true But
somehow the dialog is not modal on the application.



So I tried to implement this modal functionality as you
suggested i.e enabling and disabling the parent.That
works pretty fine.But when I close the dialog box The
parent frame is hidden and someother window that's on
task bar will be in the front.



So when I close the dialog I call the parent.toFront()
to make it appear infront of all windows.when the
dialog is closed the parent frame will come to front
after some flickering.That flickering is real bad.

Is there any better solution for the above problem.

Thanks Sumana

   <<Less

Re: Modal Dialog box and Request focus

Posted By:   Mike_Friedrich  
Posted On:   Friday, July 26, 2002 06:44 PM

Its very easy,

use this for your modal dialog:

addComponentListener(new java.awt.event.ComponentAdapter()
{
public void componentShown(java.awt.event.ComponentEvent evt)
{
myButton.requestFocus();
}
});


Regards, Mike
About | Sitemap | Contact