public TripDBPanel() {
		super (new BorderLayout ());
		
		targetDay = Calendar.getInstance();
		targetDay.setTime(new Date ());
		targetDay.add(Calendar.DATE, 1);
		Calendar startDay = Calendar.getInstance();
		startDay.setTime(MainWindow.setupData.getEventStartDate());
		if (targetDay.before(startDay))
			targetDay = startDay;

		// create table showing roster availability
		setBackground(Color.BLUE);

	    headerPanel = new JPanel ( new BorderLayout ());

	    prevDayButton = new JButton (MainWindow.getImageIcon("toolbarButtonGraphics/navigation/Back16.gif"));
	    nextDayButton = new JButton (MainWindow.getImageIcon("toolbarButtonGraphics/navigation/Forward16.gif"));
	    prevDayButton.addActionListener(this);
	    nextDayButton.addActionListener(this);
	    
	    
	    JPanel datePickerPanel = new JPanel();
		new JDateComponentFactory();
		targetDayPicker = JDateComponentFactory.createJDatePicker();
		targetDayPicker.setTextEditable(true);
		targetDayPicker.setShowYearButtons(true);
		targetDayPicker.getModel().addChangeListener(this);
		targetDayPicker.getModel().setDate(	targetDay.get(Calendar.YEAR), 
											targetDay.get(Calendar.MONTH), 
											targetDay.get(Calendar.DATE));
		targetDayPicker.getModel().setSelected(true);

		datePickerPanel.add(prevDayButton);
		datePickerPanel.add ((Component)targetDayPicker);
		datePickerPanel.add(nextDayButton);
		datePickerPanel.setBorder(BorderFactory.createLoweredBevelBorder());
		headerPanel.add(datePickerPanel, BorderLayout.WEST); 
		
		JPanel wwLevelPanel = new JPanel ();
		tfWW[0] = addStatisticsField(wwLevelPanel, "WW-I:");
		tfWW[1] = addStatisticsField(wwLevelPanel, "WW-II:");
		tfWW[2] = addStatisticsField(wwLevelPanel, "WW-III:");
		tfWW[3] = addStatisticsField(wwLevelPanel, "WW-IV:");
		tfWW[4] = addStatisticsField(wwLevelPanel, "WW-V:");
		tfTotal = addStatisticsField(wwLevelPanel, "Total:");
	    headerPanel.add (wwLevelPanel, BorderLayout.CENTER);

	    JPanel rosterPanel = new JPanel ();
	    tfRoster = addStatisticsField(rosterPanel, "FL:");
	    headerPanel.add (rosterPanel, BorderLayout.EAST);
	    
	    headerPanel.setBackground(new Color (220, 220, 220));

	    tripListModel = new DefaultListModel<TripComponent>();  
	    // create trip list in left panel
	    tripList = new JList<TripComponent> (tripListModel);
	    tripList.setCellRenderer(new TripListRenderer());
	    tripList.addListSelectionListener(this);
	    tripList.setTransferHandler(new TripListTransferHandler(this));
       // Create JTabbedPane object
        tabpanePlanningSteps = new JTabbedPane
           (JTabbedPane.TOP,JTabbedPane.SCROLL_TAB_LAYOUT );
        // create panel to select river information
        JPanel panelRivers = new JPanel ( new BorderLayout ());
        panelRivers.setBackground(Color.BLUE);
        tabpanePlanningSteps.addTab("Fl\u00FCsse", panelRivers);
	    riverListModel = new DefaultListModel<RiverComponent>();  
	    // create trip list in left panel
	    riverList = new JList<RiverComponent> (riverListModel);
	    riverList.setCellRenderer(new RiverListRenderer());
	    panelRivers.add (new JScrollPane(riverList), BorderLayout.CENTER);
	    riverList.setDragEnabled(true);
	    riverList.setTransferHandler(new RiverListTransferHandler(this));
        
	    // create panel with trip details
		JPanel panelDetails = new JPanel ( new BorderLayout ());
        panelDetails.setBackground(new Color (220, 220, 220));
        tabpanePlanningSteps.addTab("Details", panelDetails);
	    JPanel detailsGridPanel = new JPanel (new GridLayout (10,1));
	    detailsGroupNumber = new JLabel ("Gruppe ");
	    detailsGridPanel.add (detailsGroupNumber);
	    detailsRiverInfo = new JLabel ("Name km \u02AC");
	    detailsGridPanel.add (detailsRiverInfo);
	    detailsTripFrom = new JLabel ("Von: ");
	    detailsGridPanel.add (detailsTripFrom);
	    detailsTripTo = new JLabel ("Nach: ");
	    detailsGridPanel.add (detailsTripTo);
	    detailsWwLevel = new JLabel ("WW Stufe: ");
	    detailsGridPanel.add (detailsWwLevel);
	    detailsDistanceToStart = new JLabel ("Anfahrt: 0km");
	    detailsGridPanel.add (detailsDistanceToStart);
	    
	    JPanel TripTypePanel = new JPanel (new FlowLayout (FlowLayout.LEADING));
	    detailsIsEducation = new JCheckBox ("Schulung");
	    detailsIsEducation.addActionListener(this);
	    TripTypePanel.add (detailsIsEducation);
	    detailsIsKidsTour = new JCheckBox ("Kids/Teenie-Tour");
	    detailsIsKidsTour.addActionListener(this);
	    detailsIsKidsTour.setToolTipText("Autofahrer z�hlen nicht zur Gruppe dazu.");
	    TripTypePanel.add(detailsIsKidsTour);
	    detailsGridPanel.add(TripTypePanel);
	    
	    JPanel grPanel = new JPanel (new FlowLayout (FlowLayout.LEADING));
	    grPanel.add (new JLabel ("Gruppengr\u00f6\u00dfe:"));
	    Integer groupSize[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
	    detailsGroupSize = new JComboBox<Integer>(groupSize);
	    grPanel.add (detailsGroupSize);
	    detailsGroupSize.addActionListener(this);
	    detailsGridPanel.add (grPanel);
	    
	    JPanel drPanel = new JPanel (new FlowLayout (FlowLayout.LEADING));
	    drPanel.add(new JLabel ("Fahrer:"));
	    Integer drivers[] = {0, 1, 2, 3};
	    detailsDriverCount = new JComboBox<Integer>(drivers);
	    detailsDriverCount.addActionListener(this);
	    drPanel.add (detailsDriverCount);
	    detailsGridPanel.add (drPanel);
	    
        // create panel to select roster information
        JPanel panelRosters = new JPanel ( new BorderLayout ());
        panelRosters.setBackground(Color.YELLOW);
        tabpanePlanningSteps.addTab("Fahrtenleiter", panelRosters);
	    rosterListModel = new DefaultListModel<RosterComponent>();  
	    // create trip list in left panel
	    rosterList = new JList<RosterComponent> (rosterListModel);
	    rosterList.setCellRenderer(new RosterListRenderer(targetDay));
	    updateRosterList ();
	    panelRosters.add (new JScrollPane(rosterList), BorderLayout.CENTER);
	    rosterList.setDragEnabled(true);
	    rosterList.setTransferHandler(new RosterListTransferHandler(this));
	    
        //Add the start time spinner.
	    JPanel timePanel = new JPanel (new FlowLayout(FlowLayout.LEADING));
	    timePanel.add(new JLabel ("Startzeit: "));
	    SimpleDateFormat sdfWithDefaultYear = new SimpleDateFormat("HH:mm");
	    Date initDate;
		try {
			initDate = sdfWithDefaultYear.parse("10:00");
		} catch (ParseException e) {
			initDate = new Date();
		}
	    SpinnerModel dateModel = new SpinnerDateModel(initDate,
                                     null,
                                     null,
                                     Calendar.MINUTE);//ignored for user input
        detailsStartTimeSpinner = new JSpinner (dateModel);
        detailsStartTimeSpinner.setEditor(new JSpinner.DateEditor(detailsStartTimeSpinner, "HH:mm"));
        detailsStartTimeSpinner.addChangeListener(this);
        timePanel.add(detailsStartTimeSpinner);
        Calendar cal = Calendar.getInstance();
    	cal.set (Calendar.HOUR_OF_DAY, startTimeButtonStartHour);
    	cal.set (Calendar.MINUTE, startTimeButtonStartMinute);
        for (int i = 0; i < startTimeButtonsCount; i++) {
        	JButton tb = new JButton (new SimpleDateFormat("HH:mm").format(cal.getTime()));
        	tb.addActionListener(this);
        	tb.setActionCommand("SetTime");
        	timePanel.add (tb);
        	cal.add(Calendar.MINUTE, 15);
        }
	    detailsGridPanel.add (timePanel);
	    
	    panelDetails.add (detailsGridPanel, BorderLayout.NORTH);
	    
	    JPanel detailsBottomPanel = new JPanel (new BorderLayout());
	    
	    JPanel detailsRosterPanel = new JPanel (new BorderLayout());
	    detailsRosterPanel.add(new JLabel ("Fahrtenleiter"), BorderLayout.NORTH);
	    detailsRosterListModel = new DefaultListModel<RosterComponent> ();
	    detailsRosterList = new JList<RosterComponent> (detailsRosterListModel);
	    detailsRosterList.setPreferredSize(new Dimension (200, 20));
	    detailsRosterList.setVisibleRowCount(1);
	    detailsRosterList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
	    detailsRosterPanel.add (detailsRosterList, BorderLayout.CENTER);
	    detailsRosterRemoveBtn = new JButton ("Entfernen");
	    detailsRosterRemoveBtn.addActionListener(this);
	    JPanel rbPanel = new JPanel (new FlowLayout (FlowLayout.LEADING));
	    rbPanel.add (detailsRosterRemoveBtn);
	    detailsRosterRemoveBtn.setEnabled(false);
	    detailsRosterPanel.add (rbPanel, BorderLayout.SOUTH);
 	    
	    detailsBottomPanel.add (detailsRosterPanel, BorderLayout.NORTH);
	    
	    JPanel detailsCommentPanel = new JPanel (new BorderLayout());
	    detailsCommentPanel.add(new JLabel ("Bemerkung"), BorderLayout.NORTH);
	    detailsCommentText = new JTextArea ();
	    detailsCommentText.getDocument().addDocumentListener(this);
	    detailsCommentPanel.add(detailsCommentText, BorderLayout.CENTER);
	    
	    detailsBottomPanel.add (detailsCommentPanel, BorderLayout.CENTER);
	    
	    panelDetails.add (detailsBottomPanel, BorderLayout.CENTER);

	    // create panel with trip start times
        panelStartTime = new JPanel ( new FlowLayout (FlowLayout.LEADING));
        panelStartTime.setBackground(new Color (220, 220, 220));
        JScrollPane startTimesScrollPane = new JScrollPane (panelStartTime);
        tabpanePlanningSteps.addTab("Zeiten", startTimesScrollPane);

	    // create panel with print previews
        panelPreview = new PrintOutPanel (targetDay);
        panelPreview.setBackground(new Color (220, 220, 220));
        tabpanePlanningSteps.addTab("Drucken", panelPreview);
	    
	    /*
	     * Add center panel with buttons
	     */
	    JPanel btnPanel = new JPanel ( );
	    btnPanel.setLayout( new GridLayout (9,1) );

	    btnAdd = new JButton ("+ Hinzu");
	    btnPanel.add(btnAdd);
	    Dimension minSize = new Dimension(5, 10);
	    Dimension prefSize = new Dimension(5, 10);
	    Dimension maxSize = new Dimension(5, 20);
	    btnUpdate = new JButton ("\u23CE Ersetzen");
	    btnPanel.add(btnUpdate);
	    btnCopy = new JButton ("Kopie");
	    btnCopy.setEnabled(false);
	    btnPanel.add(btnCopy);
	    btnPanel.add(new Box.Filler(minSize, prefSize, maxSize));
	    btnUp = new JButton ("\u2206 Auf");
	    btnUp.setEnabled(false);
	    btnPanel.add (btnUp);
	    btnDown = new JButton ("\u2207  Ab");
	    btnDown.setEnabled(false);
	    btnPanel.add (btnDown);
	    btnPanel.add(new Box.Filler(minSize, prefSize, maxSize));
	    btnDelete = new JButton ("\u2297 L\u00F6schen");
	    btnDelete.setEnabled(false);
	    btnPanel.add(btnDelete);
	    
	    JPanel btnWrapper = new JPanel (new GridBagLayout());

	    JPanel btnAreaPanel = new JPanel (new BorderLayout ());
	    
		GridBagConstraints c = new GridBagConstraints();
		c.gridwidth = 1;
		c.gridx = 0;
		c.gridy = 1;
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.CENTER;
	    btnWrapper.add(btnPanel, c);

		btnAreaPanel.add(btnWrapper, BorderLayout.CENTER);

	    showAllRivers = new JCheckBox("Alle Flüsse");
		showAllRivers.setSelected(true);
		showAllRivers.addActionListener(this);
		c.gridy = 0;
		c.fill = GridBagConstraints.VERTICAL;
	    JPanel showAllRiversPanel = new JPanel (new BorderLayout ());
	    showAllRiversPanel.add (showAllRivers, BorderLayout.PAGE_START);
		c.anchor = GridBagConstraints.PAGE_START;
//		btnAreaPanel.add (showAllRiversPanel, c);
		btnAreaPanel.add (showAllRiversPanel, BorderLayout.PAGE_START);
	    
	    btnAdd.addActionListener(this);
	    btnAdd.setActionCommand("Add");
	    btnUpdate.addActionListener(this);
	    btnUpdate.setActionCommand("Update");
	    btnDelete.addActionListener(this);
	    btnDelete.setActionCommand("Delete");
	    btnUp.addActionListener(this);
	    btnUp.setActionCommand("Up");
	    btnDown.addActionListener(this);
	    btnDown.setActionCommand("Down");
	    btnCopy.addActionListener(this);
	    btnCopy.setActionCommand("Copy");
	    
		// left panel for trip list and buttons
		leftPanel = new JPanel (new BorderLayout ());
		leftPanel.add(new JScrollPane(tripList), BorderLayout.CENTER);
		leftPanel.add(btnAreaPanel, BorderLayout.EAST);
		
		// split pane in the center of the layout
	    JSplitPane sp = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT, leftPanel, tabpanePlanningSteps);
	    add (headerPanel, BorderLayout.NORTH);

	    c.gridwidth = 1;
		c.gridx = 0;
		c.gridy = 1;
		c.fill = GridBagConstraints.BOTH;
		c.anchor = GridBagConstraints.WEST;
	    add (sp, BorderLayout.CENTER);

	    //Provide minimum sizes for the two components in the split pane
	    leftPanel.setMinimumSize(new Dimension(350, 200));
	    tabpanePlanningSteps.setMinimumSize(new Dimension(200, 200));
	    tabpanePlanningSteps.addChangeListener(this);

	}