In my software I want to show a message "welcome " in joptionpane when the application run 1st time in that system. I do not want this message in 2nd or any more time. Only required in once when the application run 1st time in that system using netbeans .
How to show a dialog box a software using java when the software run 1st time in that system
190 views Asked by user5876281 At
2
There are 2 answers
2
On
You can create a file in somewhere in system (for example in user home directory), only create this file if not exist.
File file = new File(System.getProperty("user.dir") +"/.launch_first_time");
if(!file.exist()) {
file.createNewFile();
JOptionPane.showMessageDialog (null, "welcome", "Launch for the first time", JOptionPane.INFORMATION_MESSAGE);
}
You can run this code everytime you open the application using WindowsListener
This is probaby a good use case for Preferences: