private JPanel buildTimeEditPanel() {
		JPanel inputPanel = new JPanel();
		
		inputPanel.setLayout(new FlowLayout());

		
		toField = new TimeField();

		fromField = new TimeField();
		
		inputPanel.add(new JLabel("from: "),FlowLayout.LEFT);
		inputPanel.add(fromField, FlowLayout.CENTER);
		inputPanel.add(toField, FlowLayout.RIGHT);
		inputPanel.add(new JLabel("to: "),FlowLayout.RIGHT);
		
		
		
		JPanel buttonPanel = new JPanel(new BorderLayout());
		buttonPanel.setMaximumSize(new Dimension(2000, 100));
		
		JButton editButton = new JButton("edit");
		editButton.setFocusable(false);
		editButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				try{
					Time fromTime = new Time(fromField.getTime());
					Time toTime = new Time(toField.getTime()); 
					if(fromTime.getTimeInInt() < toTime.getTimeInInt()){
						TimeDuration newPeriod = new TimeDuration(fromTime, toTime);
						
						if(!newPeriod.equals(timeToEdit)){
								if(model.isColliding(newPeriod)){
									// needs some work, only works for editing Times not for new times, maybe add null-timeduration element
									Object[] options = {"Cut new period","Cut existing periods","Cancel"};
									int n = JOptionPane.showOptionDialog(null, "Entered timeperiod collides with existing periods. What to do?", "Collision detected!",
																		JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
									// not setting mode correctly
									if(n == TimetableModel.ADD_TIMES_MODE_CUT_EXISTING_PERIODS){
										model.setCutMode(TimetableModel.ADD_TIMES_MODE_CUT_EXISTING_PERIODS);
									}else if(n == TimetableModel.ADD_TIMES_MODE_CUT_NEW_PERIOD){
										model.setCutMode(TimetableModel.ADD_TIMES_MODE_CUT_NEW_PERIOD);
									}
								}
								model.deleteTime(timeToEdit);
								model.addTime(newPeriod);
								
								
						}		
						refresh();
						showSelectionPanel();
						pack();
					}else{
						//error
					}
				}catch(IllegalArgumentException ex){
					// error
					System.out.println(ex.getMessage());
				}
				
			}
		});
		
		JButton backButton = new JButton("back");
		backButton.setFocusable(false);
		backButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				toField.reset();
				fromField.reset();
				showSelectionPanel();
				pack();
			}
		});
		buttonPanel.add(editButton, BorderLayout.WEST);
		buttonPanel.add(backButton, BorderLayout.EAST);
		
		
		JPanel panel = new JPanel();
		BoxLayout layout = new BoxLayout(panel,BoxLayout.Y_AXIS);
		panel.setLayout(layout);
		panel.add(inputPanel);
		panel.add(buttonPanel);
		
		return panel;
	}