1

I want a "welcome" dialogue box to appear -- but only the first time the application is opened. Do I need some sort of text file in my JAR which "remembers" if the dialogue has already appeared? Is there a more elegant way of doing it than this?

Derek
  • 9,773
  • 7
  • 29
  • 34

4 Answers4

3

The Preferences API is how I did something like this. It will store a value in the Registry (Windows) or user's home folder or UNIX, so it works on everything.

http://docs.oracle.com/javase/7/docs/api/java/util/prefs/Preferences.html

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
ratbum
  • 1,030
  • 12
  • 29
0

There is not really any more elegant way of doing that, as you can't manage that kind of behavior directly in your code (directly in your jar). Saving it to a hidden file for example could be a good idea.

talnicolas
  • 13,885
  • 7
  • 36
  • 56
0

Unfortunately the best approach is probably OS dependent, ie writing to the application data folder in Windows and writing to a hidden folder in the home directory in *nix systems. You can use the preferences API for the actual preferences implementation.

Community
  • 1
  • 1
Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197
0

Does the app. have a GUI? If so, launch it using Java Web Start & use the SingleInstanceService of the JNLP API to show the '"welcome" dialogue box'.

The SIS will invoke custom code the first time an application is run. See this small demo. of the SingleInstanceService for more details, the code is available for download.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433