package com.marinilli.b2.c9;
import javax.jnlp.*;
/**
 * Chapter 9 - Customizing the standard download window
 * @author Mauro Marinilli
 * @version 1.0
 */

public class JNLPInstaller {
  ExtensionInstallerService eis;
  public JNLPInstaller() {
    try {
      eis = (ExtensionInstallerService)ServiceManager.lookup("javax.jnlp.ExtensionInstallerService");
    } catch(UnavailableServiceException use) {
      System.out.println("Service not supported: "+use);
    }
    if (eis!=null) {
      eis.setHeading("Just An Heading..");
      eis.setStatus("Here we Go!");
      for (int i=0; i<100; i++) {
        eis.updateProgress(i);
        try {
          Thread.currentThread().sleep(100);
        } catch (Exception e) {
          System.out.println(""+e);
        }
      }
      eis.setHeading("Installation Finished.");
      eis.hideProgressBar();
      try {
        Thread.currentThread().sleep(400);
      } catch (Exception e) {
        System.out.println(""+e);
      }
      boolean rebootAfterInstallation = false;
      eis.installSucceeded(rebootAfterInstallation);
    }
  }
  public static void main(String[] args) {
    JNLPInstaller JNLPInstaller1 = new JNLPInstaller();
  }
}