1

My program has the piece of code which pop-up the window dialogue box notifying the user about the ongoing process for this I'm using JOptionPane.showOptionDialog()

But when I'm starting the program as a service instead of running a jar file, I'm not able to see the pop-up window

I'm using nssm to create the service from jar/bat file

The following code is responsible to show the pop-up window

private void showWindow(String msg) {

        JTextArea textArea = new JTextArea(msg);
        textArea.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setOpaque(false);
        textArea.setEditable(false);
        textArea.setSize(new Dimension(400, 10));

        JOptionPane.showOptionDialog(null, textArea,
                "Application",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.INFORMATION_MESSAGE,
                null, null, null);

    }

I want to understand, Does service allow the program to show a window like this on a foreground?

BB1
  • 53
  • 1
  • 8
  • Have you checked in any way that your service actually runs? have it create a log file and see if, when running your service, that actually gets created – Stultuske Aug 14 '19 at 07:20
  • I believe services are headless and cannot create any GUI components. – mwarren Aug 14 '19 at 08:02
  • @Stultuske Yes, I did generate logs, The service is running fine in the background – BB1 Aug 14 '19 at 09:24

0 Answers0