public FrameMain() {
		instance = this;
		setTitle("jouse");
		setIconImage(((ImageIcon) IconUtils.getIcon("icon")).getImage());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1207, 721);
		
		menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		mnFile = new JMenu("File");
		menuBar.add(mnFile);
		
		mntmSynchronize = new JMenuItem("Synchronize");
		mntmSynchronize.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				final DialogSync dialog = new DialogSync();
				dialog.setVisible(true);
				
				new Thread(new Runnable() {
					public void run() {
						Sync.beginSync(dialog);
					}
				}).start();
			}
		});
		mntmSynchronize.setIcon(IconUtils.getIcon("item_synchronize"));
		mnFile.add(mntmSynchronize);
		
		mntmGeneratePpengine = new JMenuItem("Generate PPEngine");
		mntmGeneratePpengine.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
					PrintWriter writer = new PrintWriter(new FileWriter(new File("ppEngine.dat")));
					PPEngine.write(writer);
					writer.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		mnFile.add(mntmGeneratePpengine);
		
		mnSettings = new JMenu("Settings");
		menuBar.add(mnSettings);
		
		mntmEditActions = new JMenuItem("Edit Actions");
		mntmEditActions.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setPanel(new PanelEditActions(i));
			}
		});
		mnSettings.add(mntmEditActions);
		
		mntmEditConditions = new JMenuItem("Edit Conditions");
		mntmEditConditions.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setPanel(new PanelEditConditions(i));
			}
		});
		mnSettings.add(mntmEditConditions);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setResizeWeight(0.2);
		contentPane.add(splitPane);		
				
		JScrollPane scrollPane_tree = new JScrollPane();
		scrollPane_tree.setBorder(null);
		splitPane.setLeftComponent(scrollPane_tree);
		
		tree = new JTree();
		tree.setShowsRootHandles(true);
		rootNode = new RootTreeNode();
		model = new DefaultTreeModel(rootNode);
		tree.setCellRenderer(new MainTreeRenderer());
		tree.setModel(model);
		scrollPane_tree.setViewportView(tree);
		
		JPopupMenu popupMenu = new JPopupMenu();
		popupMenu.addPopupMenuListener(new PopupMenuListener() {
			public void popupMenuCanceled(PopupMenuEvent arg0) {
			}
			public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) {
			}
			public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
				try {
					mntmCreateObject.setEnabled(getSelectedNode() instanceof RoomTreeNode);
					mntmEditObject.setEnabled(getSelectedNode() instanceof ObjectTreeNode);
					mntmRemoveObject.setEnabled(getSelectedNode() instanceof ObjectTreeNode);
					
					mntmRemoveRoom.setEnabled(getSelectedNode() instanceof RoomTreeNode);
					mntmEditRoom.setEnabled(getSelectedNode() instanceof RoomTreeNode);
					mntmProgramObject.setEnabled(getSelectedNode() instanceof ObjectTreeNode);
					
				} catch (Exception e) {
					e.printStackTrace();
				}	
			}
		});
		addPopup(tree, popupMenu);
		
		mntmCreateRoom = new JMenuItem("Create Room");
		mntmCreateRoom.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new DialogRoomWizard().setVisible(true);
			}
		});
		mntmCreateRoom.setIcon(IconUtils.getIcon("item_room_add"));
		popupMenu.add(mntmCreateRoom);
		
		mntmRemoveRoom = new JMenuItem("Remove Room");
		mntmRemoveRoom.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				removeSelectedRoom();
			}
		});
		
		mntmEditRoom = new JMenuItem("Edit Room");
		mntmEditRoom.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				DialogRoomWizard dialog = new DialogRoomWizard();
				dialog.load(((RoomTreeNode) getSelectedNode()).getRoom());
				dialog.setVisible(true);
			}
		});
		mntmEditRoom.setIcon(IconUtils.getIcon("item_room_edit"));
		popupMenu.add(mntmEditRoom);
		mntmRemoveRoom.setIcon(IconUtils.getIcon("item_room_remove"));
		popupMenu.add(mntmRemoveRoom);
		
		popupMenu.addSeparator();
		
		mntmCreateObject = new JMenuItem("Create Object");
		mntmCreateObject.setIcon(IconUtils.getIcon("item_create_object"));
		mntmCreateObject.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new DialogObjectWizard(getSelectedRoom()).setVisible(true);
			}
		});
		popupMenu.add(mntmCreateObject);
		
		mntmRemoveObject = new JMenuItem("Remove Object");
		mntmRemoveObject.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				removeSelectedObject();
			}
		});
		
		mntmEditObject = new JMenuItem("Edit Object");
		mntmEditObject.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				DialogObjectWizard dialog = new DialogObjectWizard();
				dialog.load(((ObjectTreeNode) getSelectedNode()).getObject());
				dialog.setVisible(true);
			}
		});
		mntmEditObject.setIcon(IconUtils.getIcon("item_edit_object"));
		popupMenu.add(mntmEditObject);
		mntmRemoveObject.setIcon(IconUtils.getIcon("item_remove_object"));
		popupMenu.add(mntmRemoveObject);
		
		popupMenu.addSeparator();
		
		mntmProgramObject = new JMenuItem("Program Object");
		mntmProgramObject.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setPanel(new PanelProgramObject(getSelectedObject(), i));
			}
		});
		mntmProgramObject.setIcon(IconUtils.getIcon("item_program_object"));
		popupMenu.add(mntmProgramObject);
		
		scrollPane = new JScrollPane(new DefaultPanel());
		scrollPane.setBorder(null);
		splitPane.setRightComponent(scrollPane);
	}