Forums Register Login
Console window which stays on top
We need to start cmd.exe window from our swing application. There is no problems with that. We us next code

The problem is that user must see what happened in console when working with swing application. How can I do so that cmd window stay on top of the swing application? Another words it shouldn't be hidden by main app window when user clicks on it. It seems to me that I should set some window attributes. How can I do that? Or maybe there is a way to forward outputStream from working program to JTextArea, while this program is working?
Thank you.
Runtime.exec() returns a Process object that you can get input, output, and error streams from, and you can redirect these to/from a text area.

You could also call setState(Frame.ICONIFIED) or setVisible(false) on your frame once the console is launched to hide the frame, then use the waitFor() method of Process to listen for the end of the process, and call setState(Frame.NORMAL) or setVisible(true) to return your frame once the console process is done.
You've got three choices:

1. Use Java 1.5 (5.0) and make your console window extend "Window" (or JWindow) and call: "setAlwaysOnTop(boolean alwaysOnTop)"

2. When the console window pops up, you resize that and the main app window to fit side-by-side on the screen (see Microsoft Word and how they do this when you choose "help" for an example)

3. Use JNI. This means you'll need code for each OS it'll be installed on. If on Windows 2k/XP, look at:
a. JAWT and JAWT_Win32DrawingSurfaceInfo to get hwnd
b. Call: SetWindowPos( hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOWIZE )

Those are your options.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 974 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 21, 2018 20:17:29.