Bhargavi V 0 Light Poster

Hi All,

Can any one help me in editing a column value in a table and save the changes to the database

I am usig a piece of code as follows

private void process() {
			// Wait Cursor.
			CBRCursor waitCursor = new CBRCursor(this);
			try {
				// Get the chosen application
				String application = this.application;
				String tabletype = 	this.tabletype;		
				int warning = this.warning;
				int critical = this.critical;
				StorageDataSet data = new StorageDataSet();
				factTableRemote.getAlarmDataUpdate(application, tabletype, warning, critical).loadDataSet(data);
			
				this.getTable().setDataSet(data);
				
				TableColumnModel tableColumnModel = this.getTable().getColumnModel();
		   
			for (int col = 0; col < this.getTable().getColumnCount(); col++) {
				
		     String columnName = this.getTable().getColumnName(col);
			TableColumn column = tableColumnModel.getColumn(col);
			if (columnName.equals("Application")) {
				column.setPreferredWidth(150);
			} else if (columnName.equals("Warning"))
              {
				column.setPreferredWidth(60);
           }else if (columnName.equals("Critical"))  
			{
				column.setPreferredWidth(60);
				for(int row = 0; row < this.getTable().getRowCount(); row++){
					[B]column.setCellEditor(new MyTableCellEditor());	[/B]				}
					
			}else if (columnName.equals("Table Type"))
			{
				column.setPreferredWidth(60);
			}
		}		
			this.getTable().setVisible(true);
		} catch (Exception e) {
			CBRError.displayServerError(this, e);
		} finally {
			waitCursor.reset();
		}
	}

and the class of MyTableCellEditor() is as follows

package client.cpm.dailyT8.alarm;

import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;

@SuppressWarnings("serial")
public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {

  //public MyTableCellEditor(int warning1){
	
	JComponent component = new JTextField();
	public Component getTableCellEditorComponent(JTable table, Object value,
            boolean isSelected, int row, int column) {
		//super.getTableCellEditorComponent(table, value, isSelected, row, column);
		
		//value = warning1;
		//System.out.println(value);
	    ((JTextField)component).setText((String)value);
		System.out.println(component);
		return component;
    }

	public Object getCellEditorValue() {
        return ((JTextField)component).getText();
    }
}

I am not getting any changes in the table,

Please help me,

Thanks in Advance,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.