private void createToolBar() {

		Dimension buttonDimension = ModelerUtilities.getSystemToolBarButtonSize();

		toolBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
		toolBar.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));

		// tool for setting view angles

		ImageIcon[] icons = new ImageIcon[6];
		Class clazz = MolecularContainer.class;
		icons[0] = new ImageIcon(clazz.getResource("resources/FrontView.gif"));
		icons[0].setDescription("Present front view");
		icons[1] = new ImageIcon(clazz.getResource("resources/RearView.gif"));
		icons[1].setDescription("Present rear view");
		icons[2] = new ImageIcon(clazz.getResource("resources/TopView.gif"));
		icons[2].setDescription("Present top view");
		icons[3] = new ImageIcon(clazz.getResource("resources/BottomView.gif"));
		icons[3].setDescription("Present bottom view");
		icons[4] = new ImageIcon(clazz.getResource("resources/RightView.gif"));
		icons[4].setDescription("Present right view");
		icons[5] = new ImageIcon(clazz.getResource("resources/LeftView.gif"));
		icons[5].setDescription("Present left view");

		JComboBox comboBox = new JComboBox(icons);
		int cbWidth = icons[0].getIconWidth() + buttonDimension.width;
		cbWidth += System.getProperty("os.name").startsWith("Mac") ? 14 : 4;
		Dimension dim = new Dimension(cbWidth, buttonDimension.height);
		comboBox.setPreferredSize(dim);
		comboBox.setMaximumSize(dim);
		comboBox.setRenderer(new ComboBoxRenderer.IconRenderer());
		comboBox.setToolTipText("Set view angle");
		comboBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JComboBox cb = (JComboBox) e.getSource();
				view.setViewAngle((byte) (cb.getSelectedIndex() + MolecularView.FRONT_VIEW));
				boxRotated = true;
			}
		});
		toolBar.add(comboBox);

		// rotation tool

		rotateButton = new JToggleButton(new ImageIcon(MolecularContainer.class.getResource("resources/DefaultMode.gif")));
		rotateButton.setSelected(true);
		rotateButton.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				if (e.getStateChange() == ItemEvent.SELECTED) {
					Object o = rotateButton.getClientProperty("action_id");
					if (o instanceof Byte) {
						view.setActionID(((Byte) o).byteValue());
					}
					else {
						view.setActionID(DEFA_ID);
					}
				}
			}
		});
		rotateButton.setPreferredSize(buttonDimension);
		rotateButton.setToolTipText("Default mode");
		toolBar.add(rotateButton);
		toolBarButtonGroup.add(rotateButton);

		// pan tool

		AbstractButton button = new JToggleButton(new ImageIcon(MolecularContainer.class.getResource("resources/Pan.gif")));
		button.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				if (e.getStateChange() == ItemEvent.SELECTED) {
					view.setMode(MolecularView.DEFAULT_MODE);
					view.setActionID(PANN_ID);
				}
			}
		});
		button.setPreferredSize(buttonDimension);
		button.setToolTipText("Pan");
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// selection tool

		MouseAdapter selectMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (selectToolPopupMenu == null) {
						selectToolPopupMenu = new SelectToolPopupMenu(view);
					}
					selectToolPopupMenu.setStateID(view.getActionID());
					selectToolPopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
			}
		};
		button = new RightClickToggleButton(new ImageIcon(MolecularContainer.class.getResource("resources/selectrect.gif")), buttonDimension);
		button.addMouseListener(selectMouseAdapter);
		button.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				if (e.getStateChange() == ItemEvent.SELECTED) {
					AbstractButton b = (AbstractButton) e.getSource();
					Object o = b.getClientProperty("action_id");
					if (o instanceof Byte) {
						view.setActionID(((Byte) o).byteValue());
					}
					else {
						view.setActionID(SLRT_ID);
					}
				}
			}
		});
		button.setToolTipText("Select atoms in an area.");
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// adding atom tools

		MouseAdapter dropAtomButtonMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (dropToolPopupMenu == null) {
						dropToolPopupMenu = new DropToolPopupMenu(view);
					}
					dropToolPopupMenu.setStateID(view.getActionID());
					dropToolPopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
				else {
					AbstractButton b = (AbstractButton) e.getSource();
					b.doClick();
					if (view.isAddingAtomMode()) {
						if (elementSelectionPanel == null) {
							elementSelectionPanel = new ElementSelectionPanel(view);
						}
						elementSelectionPanel.showPopup(b);
					}
					else if (view.isAddingMoleculeMode()) {
						if (moleculeSelectionPanel == null) {
							moleculeSelectionPanel = new MoleculeSelectionPanel(view);
						}
						moleculeSelectionPanel.showPopup(b);
					}
				}
			}
		};
		final ModelAction dropAtomAction = new DefaultModelAction(model);
		dropAtomAction.setExecutable(new Executable() {
			public void execute() {
				view.setMode(MolecularView.DEFAULT_MODE);
				Object o = dropAtomAction.getValue("action_id");
				if (o instanceof Byte) {
					view.setActionID(((Byte) o).byteValue());
				}
				else {
					view.setActionID(XADD_ID);
				}
			}
		});
		button = new RightClickToggleButton(dropAtomAction, buttonDimension);
		button.addMouseListener(dropAtomButtonMouseAdapter);
		button.setIcon(new ImageIcon(MolecularContainer.class.getResource("resources/AddAtomOnXPlane.gif")));
		button.setToolTipText("Drop an atom on a plane perpendicular to the x axis");
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// adding rectangle tools

		MouseAdapter dropRectButtonMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (dropObstaclePopupMenu == null) {
						dropObstaclePopupMenu = new DropObstaclePopupMenu(view);
					}
					dropObstaclePopupMenu.setStateID(view.getActionID());
					dropObstaclePopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
			}
		};
		final ModelAction dropRectAction = new DefaultModelAction(model);
		dropRectAction.setExecutable(new Executable() {
			public void execute() {
				view.setMode(MolecularView.DEFAULT_MODE);
				Object o = dropRectAction.getValue("action_id");
				if (o instanceof Byte) {
					view.setActionID(((Byte) o).byteValue());
				}
				else {
					view.setActionID(XREC_ID);
				}
			}
		});
		button = new RightClickToggleButton(dropRectAction, buttonDimension);
		button.addMouseListener(dropRectButtonMouseAdapter);
		button.setIcon(new ImageIcon(MolecularContainer.class.getResource("resources/AddRectangleOnXPlane.gif")));
		button.setToolTipText("Draw a cuboid obstacle on a plane perpendicular to the x axis");
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// rotation tool

		MouseAdapter rotateButtonMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (rotateToolPopupMenu == null) {
						rotateToolPopupMenu = new RotateToolPopupMenu(view);
					}
					rotateToolPopupMenu.setStateID(view.getActionID());
					rotateToolPopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
			}
		};
		final ModelAction rotateAtomsAction = new DefaultModelAction(model);
		rotateAtomsAction.setExecutable(new Executable() {
			public void execute() {
				view.setMode(MolecularView.DEFAULT_MODE);
				Object o = rotateAtomsAction.getValue("action_id");
				if (o instanceof Byte) {
					view.setActionID(((Byte) o).byteValue());
				}
				else {
					view.setActionID(ROTA_ID);
				}
			}
		});
		button = new RightClickToggleButton(rotateAtomsAction, buttonDimension);
		button.setIcon(new ImageIcon(MolecularContainer.class.getResource("resources/RotateAtoms.gif")));
		button.setToolTipText("Rotate a molecule or a group of atoms");
		button.addMouseListener(rotateButtonMouseAdapter);
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// deletion tool

		MouseAdapter deleteButtonMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (deleteToolPopupMenu == null) {
						deleteToolPopupMenu = new DeleteToolPopupMenu(view);
					}
					deleteToolPopupMenu.setStateID(view.getActionID());
					deleteToolPopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
			}
		};
		final ModelAction removeAtomsAction = new DefaultModelAction(model);
		removeAtomsAction.setExecutable(new Executable() {
			public void execute() {
				view.setMode(MolecularView.DEFAULT_MODE);
				Object o = removeAtomsAction.getValue("action_id");
				if (o instanceof Byte) {
					view.setActionID(((Byte) o).byteValue());
				}
				else {
					view.setActionID(DELR_ID);
				}
			}
		});
		button = new RightClickToggleButton(removeAtomsAction, buttonDimension);
		button.setIcon(IconPool.getIcon("remove rect"));
		button.setToolTipText("Delete atoms intersected by the selected area");
		button.addMouseListener(deleteButtonMouseAdapter);
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// bonding tools

		MouseAdapter bondButtonMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (bondToolPopupMenu == null) {
						bondToolPopupMenu = new BondToolPopupMenu(view);
					}
					bondToolPopupMenu.setStateID(view.getActionID());
					bondToolPopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
			}
		};
		final ModelAction bondAction = new DefaultModelAction(model);
		bondAction.setExecutable(new Executable() {
			public void execute() {
				view.setMode(MolecularView.DEFAULT_MODE);
				Object o = bondAction.getValue("action_id");
				if (o instanceof Byte) {
					view.setActionID(((Byte) o).byteValue());
				}
				else {
					view.setActionID(RBND_ID);
				}
			}
		});
		button = new RightClickToggleButton(bondAction, buttonDimension);
		button.setIcon(IconPool.getIcon("radial bond"));
		button.setToolTipText("Build a radial bond between two atoms");
		button.addMouseListener(bondButtonMouseAdapter);
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

		// miscellaneous tools

		MouseAdapter miscButtonMouseAdapter = new MouseAdapter() {
			private boolean popupTrigger;

			public void mousePressed(MouseEvent e) {
				popupTrigger = e.isPopupTrigger();
			}

			public void mouseReleased(MouseEvent e) {
				if (popupTrigger || e.isPopupTrigger()) {
					if (miscToolPopupMenu == null) {
						miscToolPopupMenu = new MiscToolPopupMenu(view);
					}
					miscToolPopupMenu.setStateID(view.getActionID());
					miscToolPopupMenu.show((AbstractButton) e.getSource(), 5, 5);
				}
			}
		};
		final ModelAction miscAction = new DefaultModelAction(model);
		miscAction.setExecutable(new Executable() {
			public void execute() {
				view.setMode(MolecularView.DEFAULT_MODE);
				Object o = miscAction.getValue("action_id");
				if (o instanceof Byte) {
					view.setActionID(((Byte) o).byteValue());
				}
				else {
					view.setActionID(EXOB_ID);
				}
			}
		});
		button = new RightClickToggleButton(miscAction, buttonDimension);
		button.setIcon(new ImageIcon(MolecularContainer.class.getResource("resources/Extrude.gif")));
		button.setToolTipText("Extrude an obstacle by pushing/pulling its faces");
		button.addMouseListener(miscButtonMouseAdapter);
		button.setPreferredSize(buttonDimension);
		toolBar.add(button);
		toolBarButtonGroup.add(button);

	}