×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Hani Ibrahim
Added: Jan 3, 2017 3:02 AM
Modified: Feb 2, 2017 9:12 AM
Views: 7
use with snippet "Store and set preferences". Put in constructor.
  1.         // Load prefs at startup and save at shutdown
  2.         setPrefs();
  3.        
  4.         Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
  5.             @Override
  6.             public void run() {
  7.                 try{
  8.                 storePrefs();
  9.                 } catch (BackingStoreException ex){
  10.                     // do nothing
  11.                 }
  12.             }
  13.         }));