Could you be a bit more specific - what are you working with, is this a database, an excel sheet? If so, what kind? What is the statement you are using to try to change the cell?
i am using a render that extends from a tablecellrenderer and i create the jtable and set the table cell renderer, im not using a database, and i need change the cell to a combo or a checkbox, but this change all the column... :-(
look at this
/**
*
* @author adelacruz
*/
public class Renderer extends JComboBox implements TableCellRenderer{
private String type;
/**
* Creates a new instance of Renderer
*/
public Renderer(String type) {
super();
if (type == null)
return;
if (type.equals("attribute")){
addItem("String"); addItem("Long"); addItem("Integer"); addItem("Short");
addItem("Byte"); addItem("Character"); addItem("Double"); addItem("Float");
} else if (type.equals("validation")){
addItem("TXT_UPPR"); addItem("INTEGER"); addItem("DATE"); addItem("NUMERIC"); addItem("NUMERIC_TEL");
} else if (type.equals("widget")){
addItem("textfield"); addItem("checkbox"); addItem("combobox"); addItem("optionbutton");
} else if (type.equals("db")){
addItem("VARCHAR"); addItem("CHAR"); addItem("BOOL"); addItem("BIGINT"); addItem("INT");
addItem("MEDIUMINT"); addItem("DOUBLE"); addItem("DECIMAL"); addItem("FLOAT"); addItem("BLOB");
} else if (type.equals("relClass")){
addItem("*"); addItem("1..*"); addItem("1..1"); addItem("*..1");
}
this.type = type;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (type.equals("attribute") || type.equals("validation") || type.equals("widget")
|| type.equals("db") || type.equals("relClass")){
setSelectedItem(value);
return this;
}else if(value.equals("true") || value.equals("false")){
JCheckBox check = new JCheckBox();
check.setSelected((value.equals("true")?Boolean.TR UE:Boolean.FALSE));
return check;
}
return new JTextField(value.toString());
}
}
each node have a type, and depends for the type the combo im gonna display...