0

I have a java application - preferably a web-application running in a Tomcat AppServer (either on a local machine or in the cloud - java hosting).

This application shall periodically show the user a message - so that some window appears on the screen (just pops up in the center of the screen like nagging advertisement), even if my app's window is minimized or inactive (lost focus). I can do such a pop-up with Java FX in the system tray - but I need a normal window (not just a small tray popup).

Here is the problem - when my app's browser window is not active (lost focus or minified) I don't know how to bring it to the front of all other open windows and applications.

I can make some Java FX Desktop module to periodically (on timer) enable my web-app browser-window to pop up. Or I can even make the whole app in Java FX (a small Java FX utility + web app would be better though) - but I don't see how I can do it in java FX either.

I can periodically start my app with Cron to achieve this, but is there any app-programming way to do it?

My own research:

I guess there is no javascript way to do it - because the browser would isolate my web-page code from the rest of the system and won't let me interfere with more than my own web-page.

I also found that I can build a Desktop app using Electron framework and it looks like (at first glance) it supports what I need. Wiki on Electron.

Also I can write a Desktop app in Java using Qt-Wrapper library for java (Qt Jambi) - it is good to know I can use Qt from Java.

If I understood right, it seems possible in iOS/Swift and maybe possible in VB

But I need a java solution anyway. Or java + some very "thin" launcher in any other language. Maybe some activation-scheduler in some scripting language?

As to JavaFX I have tried:

  • stage.setMaximized(true);
  • stage.setAlwaysOnTop(true);
  • stage.setFocused(true);
  • stage.toFront();
  • nonPrimaryStage.initModality(Modality.APPLICATION_MODAL);

CRON-like: Scheduling program start-up for Windows 10:

Code Complete
  • 3,146
  • 1
  • 15
  • 38
  • 1
    Have you considered using the browser's Desktop Notifications API? https://www.chromium.org/developers/design-documents/desktop-notifications https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API – Faron Jan 01 '20 at 17:00
  • 1
    Try this [Wumpus example](https://stackoverflow.com/questions/24320014/how-to-call-launch-more-than-once-in-java), which is a JavaFX app that periodically shows and is set to be [always on top](https://docs.oracle.com/javase/8/javafx/api/javafx/stage/Stage.html#setAlwaysOnTop-boolean-). – jewelsea Jan 01 '20 at 20:19
  • @jewelsea It is fine, thank you! But when the user manually minimizes app's window, the app never shows up itself on timer - until the user manually clicks it on the Windows taskbar again... – Code Complete Jan 01 '20 at 21:56
  • [Remove the minimize button](https://stackoverflow.com/questions/21965855/is-it-possible-to-disable-the-minimize-button-of-a-window-in-javafx-2). – jewelsea Jan 01 '20 at 23:03

0 Answers0