public TaskManiaGUI() {


        final XMLParser parser = new XMLParser();
        graphic = new Job("root", "");


        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

            public void run() {
                Component node = (Component) jTree1.getLastSelectedPathComponent();
                if(node.getClass() == Tasks.Task.class && node.getState() == "Running"){
                    try {
                        ((Task)node).pause();
                    } catch (InvalidTransitionException ex) {
                        Logger.getLogger(TaskManiaGUI.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
               
                List<Component> tree = new ArrayList<Component>();

                int child = graphic.getChildCount();
                for (int i = 0; i < child; i++) {
                    tree.add((Component) graphic.getChildAt(i));
                }
                System.out.println(child);

                parser.saveDatabase(tree);
            }
        }));

        List<Component> database = parser.loadDatabase();
        int child = database.size();
        for (int i = 0; i < child; i++) {
            graphic.addChild(database.get(i));
        }

        try {
            String lcOSName = System.getProperty("os.name").toLowerCase();
            boolean mac = lcOSName.startsWith("mac os x");
            if (mac) {
                //colocar a barra de menu na MenuBar no mac
                System.setProperty("apple.laf.useScreenMenuBar", "true");

                // set the name of the application menu item
                //com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();

                Image logo = new ImageIcon("logo.png").getImage();;
                //macApp.setDockIconImage(logo);
            }
            // set the look and feel
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.out.println(e);
        }

        initComponents();
        setLocation(getWindowMiddle());

        updateTree(viewClosed);
        
        final Thread updater = new UpdaterThread();
        updater.setDaemon(true);
        updater.start();
    }