Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Amir Kobylinski

Greenhorn
+ Follow
since Aug 20, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amir Kobylinski

Yes but i need to have a JButton in the first row in the JTable so im sending back a JComponent ( after i recogniz. what is this )
and this work but the problem with the OutOfmemory error ...
know i can open a file ( 9,5 MB) no more ...
18 years ago
Hi
I have a [JTable(dataModel)] the datas in the dataModel are vectors so i have one vector for the header of the table and the other ( dataVector) is a vector of vector
when i'm adding something ( a text) to the dataVector i convert it to JTextField but my first row on this JTable is a JButtons so to do this I used the TableCellRenderer like following

class ComponentCellRenderer implements TableCellRenderer
{

public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {

return (JComponent)value;
}
}
my JTable is :
class TableData extends JTable {
public TableData ( TableModel model) {
setModel(model);
setDefRendAndEdit();
}

public void setDefRendAndEdit(){
setDefaultRenderer( Object.class, new ComponentCellRenderer() );
setDefaultEditor( Object.class, new ComponentCellEditor) );

}
public TableCellRenderer getCellRenderer(int row, int column) {
TableColumn tableColumn = getColumnModel().getColumn (column);
TableCellRenderer renderer = tableColumn.getCellRenderer();
if (renderer == null) {
Class c = getColumnClass(column);
Object o = getValueAt(row,column);
if( o != null ){
c = getValueAt(row,column).getClass();
renderer=getDefaultRenderer(c);
}
}

return renderer;
}

public TableCellEditor getCellEditor(int row, int column) {
TableColumn tableColumn = getColumnModel().getColumn(column);
TableCellEditor editor = tableColumn.getCellEditor();
if (editor == null) {
Class c = getColumnClass(column);
Object o = getValueAt(row,column);
if( o != null )
c = getValueAt(row,column).getClass();
editor = getDefaultEditor(c);
}

return editor;
}

}
when im using this cod to open a small file ( 112 kb) is ok .. but when it is bigger so i got a out of memory error ... the problem i think is in dataVector using
loop {
row.addElement(new JTextField(elem));
}
vectorD.addElement(row);
is better
loop{
row.addElement(elem);
}
vectorD.addElement(row);
but elem is a String not a JComponent !! so my getTableCellRendererComponent() in ComponentCellRenderer will not like it because it return JComponent !!!
how can i fix this
help please and sorry for my english
18 years ago