	public void create(KindletContext context) {
		this.ctx = context;
		this.root = ctx.getRootContainer();
		screenManager = KRepaintManager.getInstance();
		get_date();
		String[] crew_list = load_list(dir.concat("config/crew.csv"));
		Flight.init(crew_list);
		fmodel = new FlightModel(filename, save_date);
		try {
			Font menu_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,14);
			Font table_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,10);
			Font edit_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,12);
			KMenu menu = new KMenu();
			menu.add("Save",new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					fmodel.save();
					KOptionPane.showMessageDialog(root,"Data Saved");
				}
			});
			menu.add("Sync",new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					fmodel.save();
					if(python("sync.py"))
						KOptionPane.showMessageDialog(root,"Sync Completed");
					else KOptionPane.showMessageDialog(root,"Sync Failed");
				}
			});
			menu.add("Update",new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					fmodel.save();
					if(python("update.py"))
						KOptionPane.showMessageDialog(root,"Update Completed");
					else KOptionPane.showMessageDialog(root,"Update Failed");
				}
			});
			ctx.setMenu(menu);
			logs_day_info = new JLabel(date.concat("   Flights: ") 
					.concat(Integer.toString(fmodel.getFlightCount())));
			logs_day_info.setFont(menu_font);
			logs_day_info.setBorder(new LineBorder(Color.black));
			JPanel log = new JPanel(new BorderLayout()); 
			logs_cells = new JTable(fmodel);
			logs_cells.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
			logs_cells.setRowSelectionAllowed(true);
			logs_cells.setFont(table_font);
			logs_cells.setRowHeight(29);
			logs_cells.getColumnModel().getColumn(0).setPreferredWidth(50); 
			logs_cells.getColumnModel().getColumn(1).setPreferredWidth(306); 
			logs_cells.getColumnModel().getColumn(2).setPreferredWidth(130); 
			logs_cells.getColumnModel().getColumn(3).setPreferredWidth(50); 
			logs_cells.getColumnModel().getColumn(4).setPreferredWidth(50); 
			logs_cells.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					switch(e.getButton()) {
						case Gestures.BUTTON_FLICK_NORTH :
						case Gestures.BUTTON_FLICK_WEST :
							fmodel.next_page();
							break;
						case Gestures.BUTTON_FLICK_SOUTH :
						case Gestures.BUTTON_FLICK_EAST :
							fmodel.prev_page();
							break;
						case Gestures.BUTTON_HOLD : 
							Point p = e.getPoint();
							int row = logs_cells.rowAtPoint(p);
							int col = logs_cells.columnAtPoint(p);
							int flight_num = Integer.parseInt((String)logs_cells.getValueAt(row,0));
							flight = (Flight)fmodel.fdata.get(flight_num-1); 
							flight_backup = flight.toString();
							switch(col) {
								case 0 : 
									StringBuffer to_del = new StringBuffer();
									to_del.append(Integer.toString(flight_num)).append(" ?\n");
									to_del.append(' ').append(flight.name).append('\n');
									to_del.append(' ').append(flight.notes).append('\n');
									to_del.append(' ').append(flight.getAltstr()).append('\n');
									to_del.append(' ').append(new String(flight.work));
									int result = KOptionPane.showConfirmDialog(root,
											"Save A copy of flight #".concat(to_del.toString()),
											"Duplication Confirmation",
											KOptionPane.CANCEL_SAVE_OPTIONS);
									if(result!=KOptionPane.CANCEL_OPTION) {
										fmodel.addFlight((Flight)fmodel.fdata.get(flight_num-1));
										screenManager.repaint(root,false);
										break;
									}
									result = KOptionPane.showConfirmDialog(root,
											"**Delete** flight #".concat(to_del.toString()),
											"Deletion Confirmation",
											KOptionPane.NO_YES_OPTIONS);
									if(result==KOptionPane.YES_OPTION) {
										fmodel.remove(flight_num);
										update_log();
									}
									break;
								case 1 : 
									get_name(false);
									break;
								case 2 : 
								case 3 : 
								case 4 : 
									get_other(false);
									break;
								default :
							}
							break;
						case Gestures.BUTTON_GROW :
						case Gestures.BUTTON_SHRINK :
						case Gestures.BUTTON_TAP :
					}
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			logs_cells.getTableHeader().setBorder(new LineBorder(Color.black));
			log.add(logs_cells.getTableHeader(),BorderLayout.NORTH);
			log.add(logs_cells,BorderLayout.CENTER);
			JButton tandem = new JButton("Add Tandem"); 
			tandem.setFont(menu_font);
			tandem.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					int row = fmodel.fdata.indexOf(flight);
					switch(e.getButton()) {
						case Gestures.BUTTON_HOLD : 
							int pos = fmodel.fdata.size()-1;
							while(pos>=0) { 
								Flight cur = (Flight)fmodel.fdata.get(pos--);
								if(cur.solo==false) {
									fmodel.addFlight(new Flight(cur.toString()));
									screenManager.repaint(root,false);
									return;
								}
							}
						case Gestures.BUTTON_TAP : 
							flight_backup = null;
							flight = fmodel.createFlight(false,def_crew);
							get_name(false);
							break;
					}
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			JButton solo = new JButton("Add Solo"); 
			solo.setFont(menu_font);
			solo.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					int row = fmodel.fdata.indexOf(flight);
					switch(e.getButton()) {
						case Gestures.BUTTON_HOLD : 
							int pos = fmodel.fdata.size()-1;
							while(pos>=0) { 
								Flight cur = (Flight)fmodel.fdata.get(pos--);
								if(cur.solo==true) {
									fmodel.addFlight(new Flight(cur.toString()));
									screenManager.repaint(root,false);
									return;
								}
							}
						case Gestures.BUTTON_TAP : 
							flight_backup = null;
							flight = fmodel.createFlight(true,def_crew);
							get_name(true);
							break;
					}
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			JPanel log_buttons = new JPanel(new GridLayout(1,2)); 
			log_buttons.add(tandem);
			log_buttons.add(solo);
			ActionListener name_listener = new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					String name = e.getSource() instanceof JTextField ?
						name_input.getText() : ((JButton)e.getSource()).getText();
					if( name.equals("") ) return;
					flight.name = name;
					if(flight_backup==null) get_other(true); 
					else { 
						card.show(root, "logs");
					}
				}
			};
			name_input = new JTextField();
			name_input.setFont(edit_font);
			name_input.addActionListener(name_listener);
			name_input.getDocument().addDocumentListener(new DocumentListener() {
				public void changedUpdate(DocumentEvent e) { textValueChanged(e); }
				public void insertUpdate(DocumentEvent e) { textValueChanged(e); }
				public void removeUpdate(DocumentEvent e) { textValueChanged(e); }
				public void textValueChanged(DocumentEvent e) {
					Process match = null;
					BufferedReader matches = null;
					if(name_input.getText().equals("")) {
						mod_recent_names();
						return;
					}
					String[] cmd = {"/bin/sh", dir.concat(".dropbox/match_")
						.concat(flight.solo?"solo":"tandem"),name_input.getText()};
					try { 
						match = Runtime.getRuntime().exec(cmd);
						matches = new BufferedReader(new InputStreamReader(match.getInputStream()));
						String line; int i=0; Component[] buts = name_buttons.getComponents();
						while((line=matches.readLine())!=null) {
							buts[i].setEnabled(true);
							((JButton)buts[i]).setText(line);
							i++;
						}
						matches.close();
						while(i<buts.length) {
							buts[i++].setEnabled(false);
						}
						screenManager.repaint(name_buttons,false);
					} 
					catch(IOException x) { x.printStackTrace();}
				}
			});
			OnscreenKeyboardUtil.configure(name_input, OnscreenKeyboardUtil.KEYBOARD_MODE_INIT_CAP_ONCE);
			JButton name_cancel = new JButton("Cancel");
			name_cancel.setFont(edit_font);
			name_cancel.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					card.show(root, "logs");
				}
			});
			JPanel name_head = new JPanel(new BorderLayout());
			name_head.add(name_input, BorderLayout.CENTER);
			name_head.add(name_cancel, BorderLayout.EAST);
			name_buttons = new JPanel(new GridLayout(10,1));
			for(int i=0;i<10;i++) {
				JButton but = new JButton();
				but.setFont(edit_font);
				but.addActionListener(name_listener);
				name_buttons.add(but);
			}
			JLabel name_keyboard_space = new JLabel("Keyboard Space",JLabel.CENTER);
			name_keyboard_space.setPreferredSize(ctx.getOnscreenKeyboardManager().getSize());
			String[] alt_button_text = {"X","Pat","2500","3500","Mile","10k"}; 
			alt_buttons = new JPanel();
			for(int i=0;i<alt_button_text.length;i++){
				JButton but = new JButton(alt_button_text[i]);
				but.setFont(edit_font);
				but.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						int alt = flight.alt;
						alt_buttons.getComponent(alt).setEnabled(true);
						JButton but = (JButton)e.getSource(); 
						mod_alt_button(but.getText().charAt(0),false);
					}
				});
				alt_buttons.add(but);
			}
			String[] tandem_list = load_list(dir.concat("config/notes.tandem.csv"));
			String[] solo_list = load_list(dir.concat("config/notes.solo.csv"));
			notes_tandem = new JPanel(); 
			notes_solo = new JPanel();
			for(int i=0;i<tandem_list.length;i++) {
				JCheckBox but = new JCheckBox(tandem_list[i],false);
				but.setFont(edit_font);
				but.setPreferredSize(new Dimension(200,50));
				notes_tandem.add(but);
			}
			for(int i=0;i<solo_list.length;i++) {
				JCheckBox but = new JCheckBox(solo_list[i],false);
				but.setFont(edit_font);
				but.setPreferredSize(new Dimension(200,50));
				notes_solo.add(but);
			}
			card_notes = new CardLayout();
			notes = new JPanel();
			notes.setLayout(card_notes);
			notes.add(notes_tandem, "tandem");
			notes.add(notes_solo, "solo");
			work_tug = new JPanel(new GridLayout(crew_list.length,1));
			work_tug.add(new JLabel("Tug"));
			work_tug.add(new JLabel());
			work_crew = new JPanel(new GridLayout(crew_list.length,1));
			work_crew.add(new JLabel("Crew"));
			work_tandem = new JPanel(new GridLayout(crew_list.length,1));
			work_tandem.add(new JLabel("Tan"));
			work_tandem.add(new JLabel());
			for(int i=1;i<crew_list.length;i++) {
				JButton worker;
				String initial = crew_list[i].substring(0,1);
				char def_char = crew_list[i].charAt(2);
				if(def_char=='@') { 
					def_crew[2]=initial.charAt(0);
				}
				else if(def_char=='*') { 
					def_crew[0]=initial.charAt(0);
				}
				int index = crew_list[i].lastIndexOf(",");
				if(crew_list[i].charAt(index+1)=='1') {
					worker = new JButton(initial); worker.setFont(edit_font); work_crew.add(worker);
					worker.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							work_crew_but.setEnabled(true);
							work_crew_but = (JButton)e.getSource();
							flight.work[1] = work_crew_but.getText().charAt(0);
							work_crew_but.setEnabled(false);
						}
					});
				}
				if(crew_list[i].charAt(index-3)=='1') {
					worker = new JButton(initial); worker.setFont(edit_font); work_tug.add(worker);
					worker.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							work_tug_but.setEnabled(true);
							work_tug_but = (JButton)e.getSource();
							flight.work[0] = work_tug_but.getText().charAt(0);
							work_tug_but.setEnabled(false);
						}
					});
				}
				if(crew_list[i].charAt(index-1)=='1') {
					worker = new JButton(initial); worker.setFont(edit_font); work_tandem.add(worker);
					worker.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							work_tandem_but.setEnabled(true);
							work_tandem_but = (JButton)e.getSource();
							flight.work[2] = work_tandem_but.getText().charAt(0);
							work_tandem_but.setEnabled(false);
						}
					});
				}
			}
			JPanel work_logs = new JPanel(new FlowLayout(FlowLayout.CENTER,30,0));
			work_logs.add(work_tug);
			work_logs.add(work_crew);
			work_logs.add(work_tandem);
			JPanel other_center = new JPanel(new GridLayout(1,2)); 
			other_center.add(notes);
			other_center.add(work_logs);
			JButton other_save = new JButton("Save (Hold to Cancel)"); 
			other_save.setFont(menu_font);
			other_save.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					int row = fmodel.fdata.indexOf(flight);
					switch(e.getButton()) {
						case Gestures.BUTTON_HOLD : 
							if(flight_backup!=null)
								fmodel.fdata.set(row,new Flight(flight_backup));
							break;
						case Gestures.BUTTON_TAP : 
							StringBuffer new_notes = new StringBuffer();
							Component[] buts = flight.solo ?
								notes_solo.getComponents():
								notes_tandem.getComponents();
							for(int i=0;i<buts.length;i++) {
								JCheckBox but = (JCheckBox)buts[i];
								if(but.isSelected())
									new_notes.append(but.getText()).append("/");
							}
							if(new_notes.length() > 0)
								flight.notes = new_notes.deleteCharAt(new_notes.length()-1).toString();
							if(flight_backup==null) {
								fmodel.addFlight(flight);
								update_log();
							} else fmodel.update_row(row);
							break;
					}
					card.show(root,"logs");
					alt_buttons.getComponent(flight.alt).setEnabled(true);
					work_tug_but.setEnabled(true);
					work_crew_but.setEnabled(true);
					if(!flight.solo) work_tandem_but.setEnabled(true);
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			JPanel log_card = new JPanel(new BorderLayout());
			log_card.add(logs_day_info, BorderLayout.NORTH);
			log_card.add(log, BorderLayout.CENTER);
			log_card.add(log_buttons, BorderLayout.SOUTH);
			JPanel name_card = new JPanel(new BorderLayout());
			name_card.add(name_head, BorderLayout.NORTH);
			name_card.add(name_buttons, BorderLayout.CENTER);
			name_card.add(name_keyboard_space, BorderLayout.SOUTH);
			JPanel other_card = new JPanel(new BorderLayout());
			other_card.add(alt_buttons, BorderLayout.NORTH);
			other_card.add(other_center, BorderLayout.CENTER);
			other_card.add(other_save, BorderLayout.SOUTH);
			card = new CardLayout();
			root.setLayout(card);
			root.add(log_card,"logs");
			root.add(name_card,"name");
			root.add(other_card,"other");
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}

	public void create(KindletContext context) {
		this.ctx = context;
		this.root = ctx.getRootContainer();
		screenManager = KRepaintManager.getInstance();
		get_date();
		String[] crew_list = load_list(dir.concat("config/crew.csv"));
		Flight.init(crew_list);
		fmodel = new FlightModel(filename, save_date);
		try {
			Font menu_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,14);
			Font table_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,10);
			Font edit_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,12);
			KMenu menu = new KMenu();
			menu.add("Save",new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					fmodel.save();
					KOptionPane.showMessageDialog(root,"Data Saved");
				}
			});
			menu.add("Sync",new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					fmodel.save();
					if(python("sync.py"))
						KOptionPane.showMessageDialog(root,"Sync Completed");
					else KOptionPane.showMessageDialog(root,"Sync Failed");
				}
			});
			menu.add("Update",new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					fmodel.save();
					if(python("update.py"))
						KOptionPane.showMessageDialog(root,"Update Completed");
					else KOptionPane.showMessageDialog(root,"Update Failed");
				}
			});
			ctx.setMenu(menu);
			logs_day_info = new JLabel(date.concat("   Flights: ") 
					.concat(Integer.toString(fmodel.getFlightCount())));
			logs_day_info.setFont(menu_font);
			logs_day_info.setBorder(new LineBorder(Color.black));
			JPanel log = new JPanel(new BorderLayout()); 
			logs_cells = new JTable(fmodel);
			logs_cells.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
			logs_cells.setRowSelectionAllowed(true);
			logs_cells.setFont(table_font);
			logs_cells.setRowHeight(29);
			logs_cells.getColumnModel().getColumn(0).setPreferredWidth(50); 
			logs_cells.getColumnModel().getColumn(1).setPreferredWidth(306); 
			logs_cells.getColumnModel().getColumn(2).setPreferredWidth(130); 
			logs_cells.getColumnModel().getColumn(3).setPreferredWidth(50); 
			logs_cells.getColumnModel().getColumn(4).setPreferredWidth(50); 
			logs_cells.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					switch(e.getButton()) {
						case Gestures.BUTTON_FLICK_NORTH :
						case Gestures.BUTTON_FLICK_WEST :
							fmodel.next_page();
							break;
						case Gestures.BUTTON_FLICK_SOUTH :
						case Gestures.BUTTON_FLICK_EAST :
							fmodel.prev_page();
							break;
						case Gestures.BUTTON_HOLD : 
							Point p = e.getPoint();
							int row = logs_cells.rowAtPoint(p);
							int col = logs_cells.columnAtPoint(p);
							int flight_num = Integer.parseInt((String)logs_cells.getValueAt(row,0));
							flight = (Flight)fmodel.fdata.get(flight_num-1); 
							flight_backup = flight.toString();
							switch(col) {
								case 0 : 
									StringBuffer to_del = new StringBuffer();
									to_del.append(Integer.toString(flight_num)).append(" ?\n");
									to_del.append(' ').append(flight.name).append('\n');
									to_del.append(' ').append(flight.notes).append('\n');
									to_del.append(' ').append(flight.getAltstr()).append('\n');
									to_del.append(' ').append(new String(flight.work));
									int result = KOptionPane.showConfirmDialog(root,
											"Save A copy of flight #".concat(to_del.toString()),
											"Duplication Confirmation",
											KOptionPane.CANCEL_SAVE_OPTIONS);
									if(result!=KOptionPane.CANCEL_OPTION) {
										fmodel.addFlight((Flight)fmodel.fdata.get(flight_num-1));
										screenManager.repaint(root,false);
										break;
									}
									result = KOptionPane.showConfirmDialog(root,
											"**Delete** flight #".concat(to_del.toString()),
											"Deletion Confirmation",
											KOptionPane.NO_YES_OPTIONS);
									if(result==KOptionPane.YES_OPTION) {
										fmodel.remove(flight_num);
										update_log();
									}
									break;
								case 1 : 
									get_name(false);
									break;
								case 2 : 
								case 3 : 
								case 4 : 
									get_other(false);
									break;
								default :
							}
							break;
						case Gestures.BUTTON_GROW :
						case Gestures.BUTTON_SHRINK :
						case Gestures.BUTTON_TAP :
					}
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			logs_cells.getTableHeader().setBorder(new LineBorder(Color.black));
			log.add(logs_cells.getTableHeader(),BorderLayout.NORTH);
			log.add(logs_cells,BorderLayout.CENTER);
			JButton tandem = new JButton("Add Tandem"); 
			tandem.setFont(menu_font);
			tandem.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					int row = fmodel.fdata.indexOf(flight);
					switch(e.getButton()) {
						case Gestures.BUTTON_HOLD : 
							int pos = fmodel.fdata.size()-1;
							while(pos>=0) { 
								Flight cur = (Flight)fmodel.fdata.get(pos--);
								if(cur.solo==false) {
									fmodel.addFlight(new Flight(cur.toString()));
									screenManager.repaint(root,false);
									return;
								}
							}
						case Gestures.BUTTON_TAP : 
							flight_backup = null;
							flight = fmodel.createFlight(false,def_crew);
							get_name(false);
							break;
					}
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			JButton solo = new JButton("Add Solo"); 
			solo.setFont(menu_font);
			solo.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					int row = fmodel.fdata.indexOf(flight);
					switch(e.getButton()) {
						case Gestures.BUTTON_HOLD : 
							int pos = fmodel.fdata.size()-1;
							while(pos>=0) { 
								Flight cur = (Flight)fmodel.fdata.get(pos--);
								if(cur.solo==true) {
									fmodel.addFlight(new Flight(cur.toString()));
									screenManager.repaint(root,false);
									return;
								}
							}
						case Gestures.BUTTON_TAP : 
							flight_backup = null;
							flight = fmodel.createFlight(true,def_crew);
							get_name(true);
							break;
					}
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			JPanel log_buttons = new JPanel(new GridLayout(1,2)); 
			log_buttons.add(tandem);
			log_buttons.add(solo);
			ActionListener name_listener = new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					String name = e.getSource() instanceof JTextField ?
						name_input.getText() : ((JButton)e.getSource()).getText();
					if( name.equals("") ) return;
					flight.name = name;
					if(flight_backup==null) get_other(true); 
					else { 
						card.show(root, "logs");
					}
				}
			};
			name_input = new JTextField();
			name_input.setFont(edit_font);
			name_input.addActionListener(name_listener);
			name_input.getDocument().addDocumentListener(new DocumentListener() {
				public void changedUpdate(DocumentEvent e) { textValueChanged(e); }
				public void insertUpdate(DocumentEvent e) { textValueChanged(e); }
				public void removeUpdate(DocumentEvent e) { textValueChanged(e); }
				public void textValueChanged(DocumentEvent e) {
					Process match = null;
					BufferedReader matches = null;
					if(name_input.getText().equals("")) {
						mod_recent_names();
						return;
					}
					String[] cmd = {"/bin/sh", dir.concat(".dropbox/match_")
						.concat(flight.solo?"solo":"tandem"),name_input.getText()};
					try { 
						match = Runtime.getRuntime().exec(cmd);
						matches = new BufferedReader(new InputStreamReader(match.getInputStream()));
						String line; int i=0; Component[] buts = name_buttons.getComponents();
						while((line=matches.readLine())!=null) {
							buts[i].setEnabled(true);
							((JButton)buts[i]).setText(line);
							i++;
						}
						matches.close();
						while(i<buts.length) {
							buts[i++].setEnabled(false);
						}
						screenManager.repaint(name_buttons,false);
					} 
					catch(IOException x) { x.printStackTrace();}
				}
			});
			OnscreenKeyboardUtil.configure(name_input, OnscreenKeyboardUtil.KEYBOARD_MODE_INIT_CAP_ONCE);
			JButton name_cancel = new JButton("Cancel");
			name_cancel.setFont(edit_font);
			name_cancel.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					card.show(root, "logs");
				}
			});
			JPanel name_head = new JPanel(new BorderLayout());
			name_head.add(name_input, BorderLayout.CENTER);
			name_head.add(name_cancel, BorderLayout.EAST);
			name_buttons = new JPanel(new GridLayout(10,1));
			for(int i=0;i<10;i++) {
				JButton but = new JButton();
				but.setFont(edit_font);
				but.addActionListener(name_listener);
				name_buttons.add(but);
			}
			JLabel name_keyboard_space = new JLabel("Keyboard Space",JLabel.CENTER);
			name_keyboard_space.setPreferredSize(ctx.getOnscreenKeyboardManager().getSize());
			String[] alt_button_text = {"X","Pat","2500","3500","Mile","10k"}; 
			alt_buttons = new JPanel();
			for(int i=0;i<alt_button_text.length;i++){
				JButton but = new JButton(alt_button_text[i]);
				but.setFont(edit_font);
				but.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						int alt = flight.alt;
						alt_buttons.getComponent(alt).setEnabled(true);
						JButton but = (JButton)e.getSource(); 
						mod_alt_button(but.getText().charAt(0),false);
					}
				});
				alt_buttons.add(but);
			}
			String[] tandem_list = load_list(dir.concat("config/notes.tandem.csv"));
			String[] solo_list = load_list(dir.concat("config/notes.solo.csv"));
			notes_tandem = new JPanel(); 
			notes_solo = new JPanel();
			for(int i=0;i<tandem_list.length;i++) {
				JCheckBox but = new JCheckBox(tandem_list[i],false);
				but.setFont(edit_font);
				but.setPreferredSize(new Dimension(200,50));
				notes_tandem.add(but);
			}
			for(int i=0;i<solo_list.length;i++) {
				JCheckBox but = new JCheckBox(solo_list[i],false);
				but.setFont(edit_font);
				but.setPreferredSize(new Dimension(200,50));
				notes_solo.add(but);
			}
			card_notes = new CardLayout();
			notes = new JPanel();
			notes.setLayout(card_notes);
			notes.add(notes_tandem, "tandem");
			notes.add(notes_solo, "solo");
			work_tug = new JPanel(new GridLayout(crew_list.length,1));
			work_tug.add(new JLabel("Tug"));
			work_tug.add(new JLabel());
			work_crew = new JPanel(new GridLayout(crew_list.length,1));
			work_crew.add(new JLabel("Crew"));
			work_tandem = new JPanel(new GridLayout(crew_list.length,1));
			work_tandem.add(new JLabel("Tan"));
			work_tandem.add(new JLabel());
			for(int i=1;i<crew_list.length;i++) {
				JButton worker;
				String initial = crew_list[i].substring(0,1);
				char def_char = crew_list[i].charAt(2);
				if(def_char=='@') { 
					def_crew[2]=initial.charAt(0);
				}
				else if(def_char=='*') { 
					def_crew[0]=initial.charAt(0);
				}
				int index = crew_list[i].lastIndexOf(",");
				if(crew_list[i].charAt(index+1)=='1') {
					worker = new JButton(initial); worker.setFont(edit_font); work_crew.add(worker);
					worker.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							work_crew_but.setEnabled(true);
							work_crew_but = (JButton)e.getSource();
							flight.work[1] = work_crew_but.getText().charAt(0);
							work_crew_but.setEnabled(false);
						}
					});
				}
				if(crew_list[i].charAt(index-3)=='1') {
					worker = new JButton(initial); worker.setFont(edit_font); work_tug.add(worker);
					worker.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							work_tug_but.setEnabled(true);
							work_tug_but = (JButton)e.getSource();
							flight.work[0] = work_tug_but.getText().charAt(0);
							work_tug_but.setEnabled(false);
						}
					});
				}
				if(crew_list[i].charAt(index-1)=='1') {
					worker = new JButton(initial); worker.setFont(edit_font); work_tandem.add(worker);
					worker.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							work_tandem_but.setEnabled(true);
							work_tandem_but = (JButton)e.getSource();
							flight.work[2] = work_tandem_but.getText().charAt(0);
							work_tandem_but.setEnabled(false);
						}
					});
				}
			}
			JPanel work_logs = new JPanel(new FlowLayout(FlowLayout.CENTER,30,0));
			work_logs.add(work_tug);
			work_logs.add(work_crew);
			work_logs.add(work_tandem);
			JPanel other_center = new JPanel(new GridLayout(1,2)); 
			other_center.add(notes);
			other_center.add(work_logs);
			JButton other_save = new JButton("Save (Hold to Cancel)"); 
			other_save.setFont(menu_font);
			other_save.addMouseListener(new MouseListener() {
				public void mouseClicked(MouseEvent e) {
					int row = fmodel.fdata.indexOf(flight);
					switch(e.getButton()) {
						case Gestures.BUTTON_HOLD : 
							if(flight_backup!=null)
								fmodel.fdata.set(row,new Flight(flight_backup));
							break;
						case Gestures.BUTTON_TAP : 
							StringBuffer new_notes = new StringBuffer();
							Component[] buts = flight.solo ?
								notes_solo.getComponents():
								notes_tandem.getComponents();
							for(int i=0;i<buts.length;i++) {
								JCheckBox but = (JCheckBox)buts[i];
								if(but.isSelected())
									new_notes.append(but.getText()).append("/");
							}
							if(new_notes.length() > 0)
								flight.notes = new_notes.deleteCharAt(new_notes.length()-1).toString();
							else flight.notes = "";
							if(flight_backup==null) {
								fmodel.addFlight(flight);
								update_log();
							} else fmodel.update_row(row);
							break;
					}
					card.show(root,"logs");
					alt_buttons.getComponent(flight.alt).setEnabled(true);
					work_tug_but.setEnabled(true);
					work_crew_but.setEnabled(true);
					if(!flight.solo) work_tandem_but.setEnabled(true);
				}
				public void mouseReleased(MouseEvent e) { }
				public void mousePressed(MouseEvent e) { }
				public void mouseExited(MouseEvent e) { }
				public void mouseEntered(MouseEvent e) { }
			});
			JPanel log_card = new JPanel(new BorderLayout());
			log_card.add(logs_day_info, BorderLayout.NORTH);
			log_card.add(log, BorderLayout.CENTER);
			log_card.add(log_buttons, BorderLayout.SOUTH);
			JPanel name_card = new JPanel(new BorderLayout());
			name_card.add(name_head, BorderLayout.NORTH);
			name_card.add(name_buttons, BorderLayout.CENTER);
			name_card.add(name_keyboard_space, BorderLayout.SOUTH);
			JPanel other_card = new JPanel(new BorderLayout());
			other_card.add(alt_buttons, BorderLayout.NORTH);
			other_card.add(other_center, BorderLayout.CENTER);
			other_card.add(other_save, BorderLayout.SOUTH);
			card = new CardLayout();
			root.setLayout(card);
			root.add(log_card,"logs");
			root.add(name_card,"name");
			root.add(other_card,"other");
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}
