This discussion is archived
5 Replies Latest reply: Mar 11, 2013 8:20 AM by Shaylan RSS

How can I bring a process to the foreground?

Shaylan Newbie
Currently Being Moderated
I work in a manufacturing facility, and I'm working on developing a system to send process related notifications to assembly line workers. Events in an Oracle database trigger the display and use the UTL_TCP package to send a message containing a URL to the target PC. The PC has a small Java program listening for the message, which then opens the URL in Internet Explorer in kiosk mode using:
Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe -k \"" + request + "\"");
where "request" is a variable that contains the URL.

The problem I'm having is that when other applications are running, the IE window often opens behind them. I need to be able to force it to be on top of all other windows. How can I do this? I'm also open to suggestions for other approaches that don't involve using IE.

Thanks,
Shaylan

Edited by: Shaylan on Mar 11, 2013 6:25 AM

Edited by: Shaylan on Mar 11, 2013 6:26 AM
  • 1. Re: How can I bring a process to the foreground?
    gimbal2 Guru
    Currently Being Moderated
    Java 6+ has a Desktop class with which you can invoke the system default browser to display an URL. Which may just be IE of course.

    http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html

    Don't know if that will force the browser to the foreground, as soon as the process spawns you have no control over it anymore and you're at the mercy of the OS.
  • 2. Re: How can I bring a process to the foreground?
    Shaylan Newbie
    Currently Being Moderated
    Thanks for the suggestion. That does indeed cause the browser to open on top of other applications, but it still leaves me with a few different issues. I want the displayed page to take up the entire screen, hence launching IE in kiosk mode, which I don't see a way to do through the Desktop class. I also need to be able to close the browser window when I want the message to go away. In the current implementation, I'm doing this by calling the destroy() method of the Process returned from Runtime.exec().
  • 3. Re: How can I bring a process to the foreground?
    gimbal2 Guru
    Currently Being Moderated
    I guess you'll have to live with the browser not popping to the front then. You might investigate if there are more launch options for IE that do what you need, that is beyond this forum to answer.
  • 4. Re: How can I bring a process to the foreground?
    baftos Expert
    Currently Being Moderated
    I understand that the message is HTML. If it is simple HTML, Java itself can quite easily render it, as described here: http://docs.oracle.com/javase/tutorial/uiswing/components/text.html.
    You have better control than over an external process.

    If your messages are too complex for Swing based rendering, google for "java embedded browser".
  • 5. Re: How can I bring a process to the foreground?
    Shaylan Newbie
    Currently Being Moderated
    Unfortunately it isn't just simple HTML. Some of the pages I need to display are Oracle Application Express pages that dynamically generate content based on parameters passed in the URL. My first attempt actually involved using a JEditorPane to display the content, but it did a horrible job of rendering most of what I need to show. sigh I guess I'm going to be learning how to embed a browser into a java program.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points