void addGuiComponent(String fieldname) {
		String fieldguiname = (String)fieldguinames.get(fieldname)+"  ";
		String fieldtype = (String)fieldtypes.get(fieldname);
		Object fieldval = fieldvalues.get(fieldname);
		JPanel subpanel = new JPanel(new GridLayout(1,2));
		subpanel.setBackground(bgcolor);
		mainpanel.add(subpanel);
		JLabel namelabel = new JLabel(fieldguiname,JLabel.RIGHT);
		namelabel.setBackground(bgcolor);
		namelabel.setForeground(textcolor);
		namelabel.setFont(mainfont);
		if (fieldtype.equals("int")
		||  fieldtype.equals("double") ) {
			JTextField numfield = new JTextField(""+fieldval, 8);
			numfield.addCaretListener(new FieldChangeHandler(fieldname) {
				public void caretUpdate(CaretEvent e) {
					JTextField tf = (JTextField)
						fieldcomponents.get(this.fieldname);
					processAction(this.fieldname,tf.getText());
				}
			});
			if (fieldtype.equals("int")) {
				numfield.setToolTipText("Enter an integer.");
			} else {
				numfield.setToolTipText("Enter a real number.");
			}
			numfield.setFont(mainfont);
			numfield.setForeground(textcolor);
			numfield.setBackground(hltcolor);
			fieldcomponents.put(fieldname,numfield);
			subpanel.add(namelabel);
			subpanel.add(numfield);
		} else if (fieldtype.equals("String")) {
			JTextField strfield = new JTextField(""+fieldval, 8);
			strfield.addCaretListener(new FieldChangeHandler(fieldname) {
				public void caretUpdate(CaretEvent e) {
					JTextField tf = (JTextField)
						fieldcomponents.get(this.fieldname);
					processAction(this.fieldname,tf.getText());
				}
			});
			//strfield.addActionListener(new FieldChangeHandler(fieldname) {
			//	public void actionPerformed(ActionEvent e) {
			//		processAction(this.fieldname,e.getActionCommand());
			//	}
			//});
			strfield.setToolTipText("Enter a text.");
			strfield.setFont(mainfont);
			strfield.setForeground(textcolor);
			strfield.setBackground(hltcolor);
			fieldcomponents.put(fieldname,strfield);
			subpanel.add(namelabel);
			subpanel.add(strfield);
		} else if (fieldtype.equals("boolean")) {
			JCheckBox boolfield = new JCheckBox("yes");
			boolfield.addItemListener(new FieldChangeHandler(fieldname) {
				public void itemStateChanged(ItemEvent e) {
					Boolean val = new Boolean(
							e.getStateChange()==ItemEvent.SELECTED );
					processAction(this.fieldname,val);
				}
			});
			boolfield.setFont(mainfont);
			boolfield.setForeground(textcolor);
			boolfield.setBackground(bgcolor);
			fieldcomponents.put(fieldname,boolfield);
			subpanel.add(namelabel);
			subpanel.add(boolfield);
		} else if (fieldtype.equals("key")) {
			KeyField keyfield = new KeyField(fieldname,bgcolor,hltcolor);
			fieldcomponents.put(fieldname,keyfield);
			keyfield.setToolTipText(
				"Click then press a key to define keystroke." );
			keyfield.setFont(mainfont);
			keyfield.setForeground(textcolor);
			subpanel.add(namelabel);
			subpanel.add(keyfield);
		/* This is "work in progress" 
		} else if (fieldtype.equals("int2")) {
			CoordPanel copanel = new CoordPanel(
				fieldname+".",(Point)fieldval);
			copanel.setCoordListener(new FieldChangeHandler(fieldname) {
				public void coordChanged(CoordPanel src) {
					processAction(this.fieldname,src.getValue());
				}
			});
			fieldcomponents.put(fieldname,copanel);
			subpanel.add(copanel);
		} else if (fieldtype.equals("int4")) {
			CoordPanel copanel = new CoordPanel(
				fieldname+".",(Rectangle)fieldval);
			copanel.setCoordListener(new FieldChangeHandler(fieldname) {
				public void coordChanged(CoordPanel src) {
					processAction(this.fieldname,src.getValue());
				}
			});
			fieldcomponents.put(fieldname,copanel);
			subpanel.add(copanel);
		} else if (fieldtype.equals("File")) {
			// create filechooser, put it in a separate frame
			JFileChooser filechooser = new JFileChooser();
			JFrame filechframe = new JFrame("Select filename");
			filechframe.getContentPane().add(filechooser);
			filechframe.pack();
			filechooser.addActionListener(
				new FieldChangeHandler(fieldname,filechframe) {
				public void actionPerformed(ActionEvent e) {
					if (e.getActionCommand().equals("ApproveSelection")) {
						((JFrame)component).setVisible(false);
						processAction(this.fieldname,
						  ((JFileChooser)e.getSource()).getSelectedFile());
					}
				}
			});
			fieldcomponents.put(fieldname,filechooser);
			// add button to open file chooser frame
			JButton filechbut = new JButton("Select file");
			filechbut.addActionListener(new FieldChangeHandler(filechframe) {
				public void actionPerformed(ActionEvent e) {
					((JFrame)component).setVisible(true);
				}
			});
			subpanel.add(new JLabel(fieldguiname,JLabel.RIGHT));
			subpanel.add(filechbut);
		} else if (fieldtype.equals("Color")) {
			// create color chooser, put it in a separate frame
			JColorChooser colchooser = new JColorChooser((Color)fieldval);
			JFrame colchframe = new JFrame("Select colour");
			colchframe.getContentPane().add(colchooser);
			colchframe.pack();
			colchooser.getSelectionModel().addChangeListener(
				new FieldChangeHandler(fieldname,colchframe) {
				public void stateChanged(ChangeEvent e) {
					processAction( this.fieldname,
						((ColorSelectionModel)e.getSource())
							.getSelectedColor() );
					//((JFrame)component).setVisible(false);
					//System.out.println(e);
					//if (e.getActionCommand().equals("ApproveSelection")) {
					//	((JFrame)component).setVisible(false);
					//	processAction(fieldname,
					//	  ((JFileChooser)e.getSource()).getSelectedFile());
					//}
				}
			});
			fieldcomponents.put(fieldname,colchooser);
			// add button to open color chooser frame
			JButton colchbut = new JButton("Select colour");
			colchbut.addActionListener(new FieldChangeHandler(colchframe) {
				public void actionPerformed(ActionEvent e) {
					JFrame comp_frame = (JFrame) component;
					comp_frame.setVisible(!comp_frame.isVisible());
					//((JFrame)component).setVisible(true);
				}
			});
			subpanel.add(new JLabel(fieldguiname,JLabel.RIGHT));
			subpanel.add(colchbut);
		*/
		}
	}