archeaopteryx / CASnumber_lookup

Program to find chemical names from CAS numbers in an excel sheet
GNU General Public License v3.0
2 stars 1 forks source link

You could use a file chooser #1

Open Bunkerbewohner opened 4 years ago

Bunkerbewohner commented 4 years ago

https://github.com/archeaopteryx/CASnumber_lookup/blob/8cc21e9840e1b4890e46d43e3899c1548b681f5e/App.java#L91

To save your mum from having to put the .jar and the excel sheet in the same directory, you could just use a file chooser: https://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html

You also remember the chosen file, in case it's always the same, by saving the path (and any other options you want to remember) to a text file in Window's AppData folder, e.g.:

string appDataDir = System.getenv("APPDATA") + "\CASnumber_lookup";
string settingsPath = appDataDir + "\settings.txt";

// read/write settings from that file, it will persist
Bunkerbewohner commented 4 years ago

Ah... should have read the rest of the email and try the program first. Nevermind, you already figured that out of course ^^ 💪

Bunkerbewohner commented 4 years ago

Afterthought: I guess my point still stands after all. You could have her select the location of her database file once and just save it. Or does she use an empty one every time?

archeaopteryx commented 4 years ago

No, you're right. I like the suggestion of using the AppData :) Just had to hunt down some NPEs and try to handle bad input gracefully first. Thanks again for looking it over!

archeaopteryx commented 4 years ago

And no, she shouldn't use an empty one every time ^^ That wouldn't be very useful

archeaopteryx commented 4 years ago

ok, added a settings file with default location and update option.

Bunkerbewohner commented 4 years ago

Nice!