@Override
	public void actionPerformed(ActionEvent e) 
	{
		if (e.getSource() == cancelButton)
			closeWindow();
		else if (e.getSource() == okButton)
		{
			String name = (String) comboBoxUnitName.getSelectedItem();
			
			double minPos = Utility.stringToDouble(textFieldMinPos.getText());
			double maxPos = Utility.stringToDouble(textFieldMaxPos.getText());
			double minVal = Utility.stringToDouble(textFieldMinVal.getText());
			double maxVal = Utility.stringToDouble(textFieldMaxVal.getText());
			double tripTm = Utility.stringToDouble(textFieldTripTime.getText());
			
			if (   minPos == Double.MAX_VALUE
				|| maxPos == Double.MAX_VALUE
				|| minVal == Double.MAX_VALUE
				|| maxVal == Double.MAX_VALUE
				|| tripTm == Double.MAX_VALUE )
				JOptionPane.showMessageDialog(this, "Every item must have a valid number");
			else		
			{
				if (parentWindow != null)
				{
					// In case name was changed
					if (toBeEdited != null)
						parentWindow.removeUnit(toBeEditedName);
					
					// Create new Unit and add it to parent
					UnitSlew unit = new UnitSlew(name, minPos, maxPos, minVal, maxVal, tripTm);
					parentWindow.addUnit(unit);
				}
				
				closeWindow();
			}
		}
	}