Board index » jbuilder » Re: How to refocus an open (modal==false) jDialog

Re: How to refocus an open (modal==false) jDialog


2005-04-22 11:44:29 PM
jbuilder14
I have changed the from "extend JDialog" to "extend JFrame" but still
have the same question ...
Magnus wrote:
Quote
Hello,

I have a menu entry that open a dialog.
The user can go back to original screen and open a new dialog from the
same menu entry.
I would like to re-focus on the first one but can find a way to do this.

public void jMenuItem1_actionPerformed(ActionEvent e) {

// Here I want to refocus if opened before ...

Calculator dlg = new Calculator(this, "Just Test of Dialog", false);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.pack();
dlg.show();
}

Thanks in advance
 
 

Re:Re: How to refocus an open (modal==false) jDialog

Follow up on this issue:
I have a main-window that has a button to show all details for a
selected item in a list.
The window is defined as: public class ViewDetails extends JDialog {
The constructor opens this as modal=true;
While testing I had the ViewDetails opened over the main-window when I
selected to clear the desktop (i.e. no windows open). I then clicked in
the bottom toolbar to swap back to application and here is where the
problem occurred:
The process came back but the main-window was in front of the ViewDetail
window (that is smaller than the main-window). Since it was running in
modal, I could not move the main-window or get to the ViewDetail in any
way.
The way I got around this was to open another window (my browser) and
then the VIewDetail was put in front of the main-window. I minimized the
browser and could continue with my app.
Now, I can't write in the manual "if you can't see your window - open
another application and the window will appear ..."
Anyone has a solution for this behavior?
Magnus wrote:
Quote
I have changed the from "extend JDialog" to "extend JFrame" but still
have the same question ...

Magnus wrote:

>Hello,
>
>I have a menu entry that open a dialog.
>The user can go back to original screen and open a new dialog from the
>same menu entry.
>I would like to re-focus on the first one but can find a way to do this.
>
>public void jMenuItem1_actionPerformed(ActionEvent e) {
>
>// Here I want to refocus if opened before ...
>
>Calculator dlg = new Calculator(this, "Just Test of Dialog", false);
>Dimension dlgSize = dlg.getPreferredSize();
>Dimension frmSize = getSize();
>Point loc = getLocation();
>dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
>(frmSize.height - dlgSize.height) / 2 + loc.y);
>dlg.pack();
>dlg.show();
>}
>
>Thanks in advance
 

Re:Re: How to refocus an open (modal==false) jDialog

Magnus wrote:
Quote
Follow up on this issue:

I have a main-window that has a button to show all details for a
selected item in a list.

The window is defined as: public class ViewDetails extends JDialog {

The constructor opens this as modal=true;

While testing I had the ViewDetails opened over the main-window when I
selected to clear the desktop (i.e. no windows open). I then clicked in
the bottom toolbar to swap back to application and here is where the
problem occurred:

The process came back but the main-window was in front of the ViewDetail
window (that is smaller than the main-window). Since it was running in
modal, I could not move the main-window or get to the ViewDetail in any
way.

The way I got around this was to open another window (my browser) and
then the VIewDetail was put in front of the main-window. I minimized the
browser and could continue with my app.

Now, I can't write in the manual "if you can't see your window - open
another application and the window will appear ..."

Anyone has a solution for this behavior?

Submarining modal windows are a problem with many Windows applications.
This is not necessarily a Java-specific issue. I find a lot of
install programs do something similar.
I generally use "Alt-Tab" to find these sorts of "hidden" windows, not
opening another application...
You need to investigate/google focus issues and z-order issues with
modal windows/dialogs. These things tend to be very application
specific, so a solution that worked for someone else may not work for
your application.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html
 

{smallsort}

Re:Re: How to refocus an open (modal==false) jDialog

Thanks Lori,
The Alt-tab works fine and is something (in my mind) that can be put
into the manual as a "global" solution.
For the re-focus issue I will start with a flag that is set true/false
from the dialog (or any type of window) and tested on before open a new
window.
I will attack this later in more detail.
Lori M Olson [TeamB] wrote:
Quote
Magnus wrote:

>Follow up on this issue:
>
>I have a main-window that has a button to show all details for a
>selected item in a list.
>
>The window is defined as: public class ViewDetails extends JDialog {
>
>The constructor opens this as modal=true;
>
>While testing I had the ViewDetails opened over the main-window when I
>selected to clear the desktop (i.e. no windows open). I then clicked
>in the bottom toolbar to swap back to application and here is where
>the problem occurred:
>
>The process came back but the main-window was in front of the
>ViewDetail window (that is smaller than the main-window). Since it was
>running in modal, I could not move the main-window or get to the
>ViewDetail in any way.
>
>The way I got around this was to open another window (my browser) and
>then the VIewDetail was put in front of the main-window. I minimized
>the browser and could continue with my app.
>
>Now, I can't write in the manual "if you can't see your window - open
>another application and the window will appear ..."
>
>Anyone has a solution for this behavior?
>

Submarining modal windows are a problem with many Windows applications.
This is not necessarily a Java-specific issue. I find a lot of install
programs do something similar.

I generally use "Alt-Tab" to find these sorts of "hidden" windows, not
opening another application...

You need to investigate/google focus issues and z-order issues with
modal windows/dialogs. These things tend to be very application
specific, so a solution that worked for someone else may not work for
your application.