package com.marinilli.b2.c8.installer;
import javax.swing.*;
import java.awt.event.*;
import javax.jnlp.*;
/**
 * Chapter 8
 * @author Mauro Marinilli
 * @version 1.0
 */
public class Installer extends JFrame {
  public Installer() {
    setSize(400,300);
    setVisible(true);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    ExtensionInstallerService extensionInstaller = null;
    try {
      extensionInstaller =
        (ExtensionInstallerService)ServiceManager.lookup("javax.jnlp.ExtensionInstallerService");
    } catch(UnavailableServiceException use) {
      System.out.println("Service not supported: "+use);
    }
    try {
      Thread.currentThread().sleep(9000);
    } catch (Exception e) {
      System.out.println("Synchronization Exception: "+e);
    }
    extensionInstaller.installSucceeded(true);
  }
  public static void main(String[] args) {
    Installer installer = new Installer();
    if (args.length>0)
      installer.setTitle("Installation - "+args[0]);
  }
  private void jbInit() throws Exception {
    this.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        exit();
      }
    });
  }
  void exit() {
    System.exit(0);
  }
}