Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright (c) 2011 Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany.
   *  All rights reserved. This program and the accompanying materials
   *  are made available under the terms of the GNU Lesser Public License v2.1
   *  which accompanies this distribution, and is available at
   *  http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
   *
   *  Contributors:
   *      Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany - RMI Client, FileChooser and WebDAV
  */
 package de.ipk_gatersleben.bit.bi.edal.rmi.client.util;
 
 
 
 public class PersonTableCellEditor extends JComboBox<Stringimplements TableCellEditor{
 	private static final long serialVersionUID = 1L;
 	private JTable table;
 	private int row;
 	private int col;
 
 	public PersonTableCellEditor(final String[] values,final boolean bindevent) {
         super();
         for(String value:values)
         {
         	addItem(value);
         }
         
        
         this.addItemListener(new ItemListener() {
                  public void itemStateChanged(ItemEvent e) {
                      if (e.getStateChange() == .) {
                     	 if(bindevent)
                     	 {
                     		 if(e.getItem().toString().equals(values[0]))
                              {
                              	.getColumnModel().getColumn(1).setCellEditor(new ReadonlyTableCellEditor(false));
                              	.getColumnModel().getColumn(2).setCellEditor(new ReadonlyTableCellEditor(false));
                              	.getColumnModel().getColumn(3).setCellEditor(new ReadonlyTableCellEditor(true));
                              }
                              else
                              {
                              	.getColumnModel().getColumn(1).setCellEditor(new ReadonlyTableCellEditor(true));
                              	.getColumnModel().getColumn(2).setCellEditor(new ReadonlyTableCellEditor(true));
                              	.getColumnModel().getColumn(3).setCellEditor(new ReadonlyTableCellEditor(false));
                              }
                     	 }                        
                          .getModel().setValueAt(e.getItem(), );
                          ..println("new data:"+e.getItem());
                          .updateUI();
                          //((DefaultTableModel)table.getModel()).fireTableDataChanged();
                      }
                  }
         });
     }
 	
             boolean isSelectedint row,
             int column) {
 		this. = table;
 		this. = row;
 		this. = column;
 		return this;
 	}
 
 	public void cancelCellEditing() {
 	}
 
 	public boolean stopCellEditing() {
 		return true;
 	}
 
 	public Object getCellEditorValue() {
         return this.getSelectedItem();
     }
 	
 	public void setValue(final Object value) {
         this.setSelectedItem(value);
     }
 
 	public boolean isCellEditable(EventObject anEvent) {
 		return true;
 	}
 
 	public boolean shouldSelectCell(EventObject anEvent) {
 		if (anEvent instanceof MouseEvent) {
             final MouseEvent e = (MouseEventanEvent;
             return e.getID() != .;
         }
         return true;
 	}
	}
	}
New to GrepCode? Check out our FAQ X