public BookingWindow(MainWindow mainWindow, Student stu)
			throws ParseException, InstanceNotFoundException {
		sdf = new SimpleDateFormat(DATE_FORMAT);
		this.student = stu;
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 657, 454);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new GridLayout(1, 0, 0, 0));

		JPanel panel = new JPanel();
		contentPane.add(panel);

		calendar = new JCalendar();
		calendar.getYearChooser().setEnabled(false);
		calendar.getDayChooser().addPropertyChangeListener(
				new PropertyChangeListener() {
					public void propertyChange(PropertyChangeEvent evt) {
						if (evt.getPropertyName().equals("day"))
							fldPlaces.setText(String.valueOf(bookingService
									.getPlacesForDiningSchedule(calendar
											.getCalendar(),
											(DiningHall) comboBox
													.getSelectedItem())));
						fillBookings();
					}
				});
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel.createSequentialGroup()
						.addComponent(calendar, GroupLayout.PREFERRED_SIZE,
								315, GroupLayout.PREFERRED_SIZE)
						.addContainerGap(GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		gl_panel.setVerticalGroup(gl_panel.createParallelGroup(
				Alignment.LEADING).addComponent(calendar,
				GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE));
		panel.setLayout(gl_panel);

		JPanel panel_1 = new JPanel();
		contentPane.add(panel_1);

		JLabel lblAlumno = new JLabel("Alumno : ");

		JLabel lblCurso = new JLabel("Curso :");

		fldAlumno = new JTextField();
		lblAlumno.setLabelFor(fldAlumno);
		fldAlumno.setEditable(false);
		fldAlumno.setColumns(10);
		fldAlumno.setText(student.getLastname() + " , " + student.getName());

		fldCurso = new JTextField();
		lblCurso.setLabelFor(fldCurso);
		fldCurso.setText("Curso");
		fldCurso.setEditable(false);
		fldCurso.setColumns(10);
		fldCurso.setText(familyService.getStudentType(this.student));

		JSeparator separator = new JSeparator();
		separator.setSize(new Dimension(200, 0));

		JScrollPane scrollPane = new JScrollPane();

		JLabel lblHorario = new JLabel("Horario : ");

		comboBox = new JComboBox<DiningHall>();

		List<DiningHall> diningHall = bookingService.getDiningHall();

		for (int i = 0; i < diningHall.size(); i++) {
			comboBox.addItem(diningHall.get(i));
		}

		comboBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				fldPlaces.setText(String.valueOf(bookingService
						.getPlacesForDiningSchedule(calendar.getCalendar(),
								(DiningHall) comboBox.getSelectedItem())));
			}
		});

		JLabel lblMonitors = new JLabel("Monitores : ");

		fldPlaces = new JTextField();
		fldPlaces.setEditable(false);
		fldPlaces.setColumns(10);

		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new LineBorder(Color.LIGHT_GRAY));

		btnDeleteBooking = new JButton("Cancelar reserva");
		btnDeleteBooking.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				int select = JOptionPane.showConfirmDialog(null,
						"¿Realmente desea cancelar la reserva?",
						"Cancelar reserva", JOptionPane.YES_NO_OPTION,
						JOptionPane.QUESTION_MESSAGE);
				if (select == 0) {
					Booking selected = (Booking) bookingsTable.getModel()
							.getValueAt(bookingsTable.getSelectedRow(), 2);

					try {
						bookingService.remove(selected);
					} catch (InstanceNotFoundException e) {
						e.printStackTrace();
					}
					fillBookings();
				}
			}
		});

		JButton btnReservar = new JButton("Realizar reserva");
		btnReservar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
					if (!daysAreChecked()) {
						Calendar cal = Calendar.getInstance();
						cal.setTime(calendar.getCalendar().getTime());
						Booking b = new Booking(cal, student,
								(DiningHall) comboBox.getSelectedItem());
						try {
							bookingService.create(b);
						} catch (NotValidDateException e) {
							JOptionPane.showMessageDialog(null,
									"El dia " + sdf.format(cal.getTime())
											+ " es festivo");
						}
						fldPlaces.setText(String.valueOf(bookingService.getPlacesForDiningSchedule(
								calendar.getCalendar(),
								(DiningHall) comboBox.getSelectedItem())));
					} else {
						createBookingsPerMonth(calendar.getCalendar().get(
								Calendar.MONTH));
					}
				} catch (DuplicateInstanceException e) {
					JOptionPane
							.showMessageDialog(null,
									"La reserva para el alumno y el horario establecido ya existe");
				} catch (MaxCapacityException e) {
					JOptionPane
							.showMessageDialog(null,
									"No quedan plazas disponibles para el horario seleccionado");
				}
				fillBookings();
			}
		});

		JButton btnVolver = new JButton("Volver");
		btnVolver.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookingWindow thisWindow = (BookingWindow) ((JButton) e
						.getSource()).getTopLevelAncestor();
				mainWindow.fillRightPanel(mainWindow.getRigthPanel());
				thisWindow.setVisible(false);
				thisWindow.dispose();
			}
		});
		GroupLayout gl_panel_1 = new GroupLayout(panel_1);
		gl_panel_1
				.setHorizontalGroup(gl_panel_1
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_1
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												gl_panel_1
														.createParallelGroup(
																Alignment.TRAILING)
														.addComponent(
																scrollPane,
																GroupLayout.DEFAULT_SIZE,
																295,
																Short.MAX_VALUE)
														.addComponent(
																separator,
																GroupLayout.DEFAULT_SIZE,
																295,
																Short.MAX_VALUE)
														.addGroup(
																gl_panel_1
																		.createSequentialGroup()
																		.addGroup(
																				gl_panel_1
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								lblAlumno)
																						.addComponent(
																								lblCurso))
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addGroup(
																				gl_panel_1
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								fldCurso,
																								GroupLayout.DEFAULT_SIZE,
																								246,
																								Short.MAX_VALUE)
																						.addComponent(
																								fldAlumno,
																								GroupLayout.DEFAULT_SIZE,
																								246,
																								Short.MAX_VALUE)))
														.addGroup(
																gl_panel_1
																		.createSequentialGroup()
																		.addGroup(
																				gl_panel_1
																						.createParallelGroup(
																								Alignment.TRAILING)
																						.addComponent(
																								lblMonitors)
																						.addComponent(
																								lblHorario))
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addGroup(
																				gl_panel_1
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								comboBox,
																								0,
																								234,
																								Short.MAX_VALUE)
																						.addComponent(
																								fldPlaces,
																								GroupLayout.PREFERRED_SIZE,
																								58,
																								GroupLayout.PREFERRED_SIZE)))
														.addComponent(
																btnDeleteBooking)
														.addComponent(
																panel_2,
																GroupLayout.DEFAULT_SIZE,
																295,
																Short.MAX_VALUE)
														.addGroup(
																gl_panel_1
																		.createSequentialGroup()
																		.addComponent(
																				btnReservar)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				btnVolver)))
										.addContainerGap()));
		gl_panel_1
				.setVerticalGroup(gl_panel_1
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_1
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												gl_panel_1
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(lblAlumno)
														.addComponent(
																fldAlumno,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												gl_panel_1
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(lblCurso)
														.addComponent(
																fldCurso,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addComponent(scrollPane,
												GroupLayout.PREFERRED_SIZE,
												107, GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addComponent(btnDeleteBooking)
										.addGap(5)
										.addComponent(separator,
												GroupLayout.PREFERRED_SIZE, 10,
												GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												gl_panel_1
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblHorario)
														.addComponent(
																comboBox,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												ComponentPlacement.UNRELATED)
										.addGroup(
												gl_panel_1
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblMonitors)
														.addComponent(
																fldPlaces,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addComponent(panel_2,
												GroupLayout.PREFERRED_SIZE, 59,
												Short.MAX_VALUE)
										.addGap(18)
										.addGroup(
												gl_panel_1
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(btnVolver)
														.addComponent(
																btnReservar))
										.addContainerGap()));

		bookingsTable = new JTable();
		bookingsTable.setModel(new DefaultTableModel(new Object[][] {},
				new String[] { "Fecha", "Tipo horario", "Objeto" }));
		bookingsTable.getColumnModel().getColumn(2).setMinWidth(0);
		bookingsTable.getColumnModel().getColumn(2).setMaxWidth(0);
		bookingsTable.getColumnModel().getColumn(2).setWidth(0);
		scrollPane.setViewportView(bookingsTable);

		JLabel lblReservaSemanal = new JLabel("Reserva : ");

		chckbxLun = new JCheckBox("lun");
		chckbxLun.setEnabled(false);

		chckbxMar = new JCheckBox("mar");
		chckbxMar.setEnabled(false);

		chckbxMie = new JCheckBox("mie");
		chckbxMie.setEnabled(false);

		chckbxJue = new JCheckBox("jue");
		chckbxJue.setEnabled(false);

		chckbxVie = new JCheckBox("vie");
		chckbxVie.setEnabled(false);

		JRadioButton rdbtnDay = new JRadioButton("diaria");
		rdbtnDay.setSelected(true);
		rdbtnDay.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				chckbxLun.setEnabled(false);
				chckbxLun.setSelected(false);
				chckbxMar.setEnabled(false);
				chckbxMar.setSelected(false);
				chckbxMie.setEnabled(false);
				chckbxMie.setSelected(false);
				chckbxJue.setEnabled(false);
				chckbxJue.setSelected(false);
				chckbxVie.setEnabled(false);
				chckbxVie.setSelected(false);
			}
		});

		JRadioButton rdbtnMonth = new JRadioButton("mensual");
		rdbtnMonth.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				chckbxLun.setEnabled(true);
				chckbxMar.setEnabled(true);
				chckbxMie.setEnabled(true);
				chckbxJue.setEnabled(true);
				chckbxVie.setEnabled(true);
			}
		});
		ButtonGroup group = new ButtonGroup();
		group.add(rdbtnDay);
		group.add(rdbtnMonth);

		GroupLayout gl_panel_2 = new GroupLayout(panel_2);
		gl_panel_2
				.setHorizontalGroup(gl_panel_2
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_2
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												gl_panel_2
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_panel_2
																		.createSequentialGroup()
																		.addComponent(
																				chckbxLun)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				chckbxMar)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				chckbxMie)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				chckbxJue)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				chckbxVie))
														.addGroup(
																gl_panel_2
																		.createSequentialGroup()
																		.addComponent(
																				lblReservaSemanal)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				rdbtnDay)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				rdbtnMonth)))
										.addContainerGap(84, Short.MAX_VALUE)));
		gl_panel_2
				.setVerticalGroup(gl_panel_2
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_2
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												gl_panel_2
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblReservaSemanal)
														.addComponent(rdbtnDay)
														.addComponent(
																rdbtnMonth))
										.addPreferredGap(
												ComponentPlacement.UNRELATED)
										.addGroup(
												gl_panel_2
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(chckbxLun)
														.addComponent(chckbxMar)
														.addComponent(chckbxMie)
														.addComponent(chckbxJue)
														.addComponent(chckbxVie))
										.addContainerGap(23, Short.MAX_VALUE)));
		panel_2.setLayout(gl_panel_2);
		panel_1.setLayout(gl_panel_1);

	}