Java Snippet - Splash screen

Dear friends,
It took several months to find a new silly question :slight_smile:
I’d like to get notes about the progress of the workflow in a splash screen notifying that e.g. after execution of this exact node we have x results or “Sorry, no results - I try alternative approach”.

For years I used Java Snippet with JOptionPane.showMessageDialog to handle this issue and it was OK to me, but now I’d like to have a splash screen instead of message dialog. Just a note appearing for a couple of seconds and proceeding further with execution of the workflow.

Unfortunately, my java skills is a little below zero. I tried for a day and failed.
Occasionally I found java script
https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/SplashDemoProject/src/misc/SplashDemo.java which is probably more advanced then I need, but it may work.

Can you give me a hand with this? I’m sure that message box opening for a limited time with appropriate note may be of interest to other members of the community as well.

Wish you a nice day,
Dmitry

Dear DmitryIvanov76,

unfortunately, the SplashScreen is not the right option for your use case. A SplashScreen is used specifically for displaying a small window before a Java application startup, and can/should not be used as an intermediate message popup during the WF execution (or during a running Java application in general).

Your previous option with the JOptionPane is a quick way to achieve that. May I ask why you want to switch your message popup? Maybe then I can help you better at what you are trying to do. :slight_smile:

Have a nice day,
Leon

3 Likes

Dear Leon,

Thank you very much for your reply.

What I’d like to archive is to have something like text notifiers about progress of the workflow execution.

Now I have these notifiers as a series of msgboxes appearing with “OK” button and a text.
Certainly, if workflow execution takes 5-7 minutes and you have 2-3 notifiers it’s not a problem to press “OK” button in the message box, but in larger workflows (or if you like to have more notifiers) this approach is inconvenient.
That’s why I’m searching for something like “auto close” feature of message boxes ensuring that in the outcome I will not have several opened boxes to close after the execution.
I hope my words makes sense :slight_smile:

Wish you all the best,
Dmitry

1 Like

Dear DmitryIvanov76,

in this case you can still use your previous approach with the JOptionPane.
The only differences are to use a Timer to auto-close the dialog after a few seconds, and a slightly different dialog creation.
Here is an example code snippet which you can use and tweak to show a message dialog for a certain number of seconds.

void showMessageDialog(String title, String message, int autoCloseSeconds) {
	// Choose other JOptionPane.* attributes for different dialog types.
	int dialogType = JOptionPane.INFORMATION_MESSAGE;
	JDialog dialog = new JOptionPane(message, dialogType).createDialog(null, title);

	// Setting up auto-close timer, then showing dialog.
	Timer timer = new Timer(1000 * autoCloseSeconds, e -> dialog.dispose());
	timer.start();
	dialog.setVisible(true);
}

I hope this helps!

Best regards,
Leon

2 Likes

Dear Leon!

Thank you very much! I’m sure this solution will be of interest to many users of KNIME.
Your help and expertise are very appreciated.

Have a nice day and all the best :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.