please, i need to change only one cell, but i only get change all the column of the table... i am beginner, and im learning english, je je je sorry
need help with a render a cell
Collapse
X
-
Tags: None
-
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?Originally posted by andrea8288please, i need to change only one cell, but i only get change all the column of the table... -
i am using a render that extends from a tablecellrender er 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... :-(Originally posted by sicarieCould 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?
look at this
/**
*
* @author adelacruz
*/
public class Renderer extends JComboBox implements TableCellRender er{
private String type;
/**
* Creates a new instance of Renderer
*/
public Renderer(String type) {
super();
if (type == null)
return;
if (type.equals("a ttribute")){
addItem("String "); addItem("Long") ; addItem("Intege r"); addItem("Short" );
addItem("Byte") ; addItem("Charac ter"); addItem("Double "); addItem("Float" );
} else if (type.equals("v alidation")){
addItem("TXT_UP PR"); addItem("INTEGE R"); addItem("DATE") ; addItem("NUMERI C"); addItem("NUMERI C_TEL");
} else if (type.equals("w idget")){
addItem("textfi eld"); addItem("checkb ox"); addItem("combob ox"); addItem("option button");
} else if (type.equals("d b")){
addItem("VARCHA R"); addItem("CHAR") ; addItem("BOOL") ; addItem("BIGINT "); addItem("INT");
addItem("MEDIUM INT"); addItem("DOUBLE "); addItem("DECIMA L"); addItem("FLOAT" ); addItem("BLOB") ;
} else if (type.equals("r elClass")){
addItem("*"); addItem("1..*") ; addItem("1..1") ; addItem("*..1") ;
}
this.type = type;
}
public Component getTableCellRen dererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (type.equals("a ttribute") || type.equals("va lidation") || type.equals("wi dget")
|| type.equals("db ") || type.equals("re lClass")){
setSelectedItem (value);
return this;
}else if(value.equals ("true") || value.equals("f alse")){
JCheckBox check = new JCheckBox();
check.setSelect ed((value.equal s("true")?Boole an.TRUE:Boolean .FALSE));
return check;
}
return new JTextField(valu e.toString());
}
}
each node have a type, and depends for the type the combo im gonna display...Comment
-
-
no problem, i know you are too busy, not is only me who need help
well, it was so easy, that i feel like a fool... i did a renderer class and an editor class, i too did a class tableproperties and there i overwrite getCellRenderer and getCellEditor ;-)Comment
-
jejeje... but if you feel too bad, you still can help me, jejeje, because now the problem is that i cant set the value of the cell ;-DComment
Comment