Hi Cynthia and y'all --
Two notes for this thread...
1. Win2K gets same results as NT (details below).
2. I have a suggestion (below) to make it "portable."
I hope this helps.
cheers,
-ken
BTW, thanks for this brain-twister.
First time I've done Java all week,
& more fun than updating my resume'!
(I'm looking for work this month.)
;-)
POINT 1 - works on Win2K just like NT
I just tried your example app on Win2K for fun, and first instance pops up
in front only when launched from inside Together -- not when launched from
"cmd" window. So, indeed, the problem you reported seems to be NT-specific.
I didn't see Win2K mentioned in your list, so I wasn't sure if you had a
Win2K system to test it on. I wondered whether it would be the same as NT
or not, because MS splash screens say "built on NT" whatever. (Which NT are
you using? Is it Build 1381 Service Pack 5?)
I am launching it from within Together ControlCenter 5.02 (build 1345), and
Java(TM) 2 SDK, Standard Edition Version 1.3.0, off-the-shelf as installed.
I'm using a Dell C600 Pentium III and Windows 2000 (SP2, I think). For the
command line launching, I'm doing a Start/Run.../"cmd" shell.
DETAILS: I checked the visual Z-order. The new frame does appear in front
of the CMD shell window if that was kept in front, but behind the last
"other" window brought to the front before the timer expires. Curiously,
the Z-order of the pop-up is exactly one (1) behind the
most-recently-brought-to-front window. If you bring several to front after
starting the command, when the thing pops, it will slip in just behind the
front-most window. Go figure!
POINT 2 - a cheap "portability" hack
Add a trivial one-shot splash-screen, something to use as a throw-away.
Just pop it up when the GUI-less server is started, and then close it and
forget about it. If all pop-ups after that first one are brought to the
front by NT, then so be it! ;-)
DISCLAIMER: Yeah, I know, it seems like a kluge. It is. No shame. My
suggestion comes from years of finding work-arounds for multi-platform
frameworks, such as the Intersolv Maintenance Workbench (MWB), built at
InterPort, using XVT and runnable MS Windows, IBM OS/2 Presentation Manager,
VAX Ultrix w/Motif, and even a VMS port (in the early 1990's). Every now
and then, we had to do something "dumb" like this to normalize the behavior
of our framework across several target platforms.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Cynthia
Jeness
Sent: Wednesday, September 26, 2001 8:16 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]; Eric Faulhaber; Gregory Shah; Brian Hedges
Subject: Java Application Z-order Problem under NT (previously starts
minimized)
We are having a problem getting our Swing application to display in front of
other running
applications the FIRST time that it attempts to display a JFrame. To
provide some
background, we have a Java application which is always running and which
provides a TCP/IP
server. Client applications written in other languages can connect to this
server and
request it to execute Java classes. Some of these requests involve
launching a JFrame
window. On NT only, the very FIRST time that such a request is made, the
JFrame is
displayed behind the requesting application. The second and later times
such a request is
received, the Java application displays correctly on top. Our application
always runs
correctly on Unix (Solaris and Linux) and OS/2.
In order to illustrate the problem, I developed a small test application
(Java source code
attached). To reproduce the problem, compile the source and type the
following:
java DelayedDisplay
in a command window. Then bring up some other application (e.g. Netscape or
IE) and make
sure that it is close to the upper left hand corner. After about 30
seconds, our JFrame
should pop up. Its position is (0, 0), but it will be hidden by the other
application.
Now click on the hide button and give the other GUI application the focus
again. In
another 30 seconds the JFrame will pop up again, but this time it will
display on top of
the other GUI application which is what we want.
You can set the delay to a shorter time with the following:
java DelayedDisplay 10
where "10" would be the wait time in seconds.
My source code attempts to incorporate all of the suggestions previously
made on the Swing
list, but none seem to solve the problem. We are using the Sun JDK 1.3.1
for Windows. My
test machine has Windows NT FixPak 3.
To kill the application, just press the window close icon.
Cynthia Jeness
Foudili Kacem wrote:
> Hi Cynthia,
> Hi, I had a similar problem time ago, and I modified
> my code as following to get a better result...
>
> if(frame.getState()==Frame.ICONIFIED)
> frame.setState(Frame.NORMAL);
> frame.setVisible(true);
> frame.requestFocus();
>
> Hope it helps.
> K.
>
> ------------------------------------
> At 12:59 22/09/2001 -0400, you wrote:
>
> Christian,
>
> Here is the code that I use. I added the "toFront()" and changed "show()"
> to
> "setVisible(true)", but this has no effect. Again, I don't have any
> problem if
> I simply start a Swing applicaton on NT. The problem arises when we have
an
> already running non-GUI TCP/IP Java server application which is request to
> start
> a Swing application. The problem occurs whether or not the the MSDOS
window
> containing the TCP/IP Java server is maximized and has the focus or not.
>
> Cynthia Jeness
>
> --------------------------------------------------------------------------
--------------
>
> /**
> * This method sizes the frame and shows it. The window is
> * sized at a maximum of MAX_WINDOW_WIDTH X MAX_WINDOW_HEIGHT and
> * centered on the screen.
> */
> public void showFrame() {
>
> // If any error during initialization, then return.
> if (initError)
> return;
>
> // Size the frame and display it in the middle of the screen.
> Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
> int width = Math.min(Constants.MAX_WINDOW_WIDTH, screen.width);
> int height = Math.min(Constants.MAX_WINDOW_HEIGHT, screen.height);
> int left = (screen.width - width)/2;
> int top = (screen.height - height)/2;
> setBounds(left, top, width, height);
>
> // Trying to force visibility on Windows.
> toFront();
> setVisible(true);
> //show();
> windowOpen = true;
> }
>
> Christian Pesch wrote:
>
> >Cynthia Jeness schrieb:
> >
> > > We have a legacy GUI application which communicates with a Java TCP/IP
> > > server application running on the same computer. Depending on the
type
> > > of message received, we load a JFrame which contains a JTabbedPane.
The
> > > application is launched correctly. However, at least under NT, it is
> > > minimized and, thus, you must select it from the Taskbar to actually
see
> > > it. The application is launched correctly under OS/2. In the case of
> > > NT, we are using the latest JDK 1.3.1 from Sun. I have tried
explicitly
> > > setting the state of the frame to NORMAL. But this has no effect.
> >
> >I use the following code sequence to open frames and bring them to front
> >with JDK 1.3.1 Windows NT and 2000:
> >
> >if(System.getProperty("os.name").startsWith("Windows")) {
> > Gui.getLog().write(Log.LEVEL_INFO, "Enabled Windows window to front
> >patch");
> >
> > enableWindowsPatch = true;
> >}
> >
> >Then opening does this
> >
> > // workaround for windows to bring frame to front
> > if(enableWindowsPatch)
> > frame.toFront();
> >
> > frame.setVisible(true);
> >
> > > Does
> > > anyone have any suggestions about how to get the application launched
in
> > > a normal size. If I launch it from the command line on NT rather than
> > > from an already running Java application, then the window is displayed
> > > correctly on NT.
> >
> >Please extract your code sequence to show a frame. May that shows up
> >an error.
> >
> >--
> >Christian Pesch - Software Engineer
> >CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA
> >Visit us on the Systems, M�nchen and Orbit, Basel
>
> _______________________________________________
> Swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/swing
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
> _______________________________________________
> Swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/swing
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing