JTable se value

I'm trying to set the values at in my JTable but the values aren't appearing.

Heres my code, can anyone tell me what I'm doing wrong?

import javax.swing.JDialog;

import javax.swing.JScrollPane;

import javax.swing.JTable;

import javax.swing.table.AbstractTableModel;

import javax.swing.table.TableModel;

publicclass CreateJTableextends JDialog{

public CreateJTable(){

TableModel dataModel =new AbstractTableModel(){

publicint getColumnCount(){

return 4;

}

publicint getRowCount(){

return 10;

}

public Object getValueAt(int row,int col){

return" ";

}

};

JTable table =new JTable(dataModel);

table.setValueAt("#", 0, 0);

table.setValueAt("Aplaha", 2, 2);

// Retrieve the value in the visible cell (1,2)

int rowIndex = 1;

int vColIndex = 2;

Object o = table.getValueAt(rowIndex, vColIndex);

// Retrieve the value in cell (1,2) from the model

rowIndex = 1;

int mColIndex = 2;

o = table.getModel().getValueAt(rowIndex, mColIndex);

// Change a cell in the 2nd visible column

rowIndex = 2;

vColIndex = 1;

table.setValueAt("New Value", rowIndex, vColIndex);

// Change a cell in the 3rd column in the model

rowIndex = 3;

mColIndex = 2;

table.getModel().setValueAt("New Value", rowIndex, mColIndex);

JScrollPane scrollpane =new JScrollPane(table);

setSize(400, 400);

getContentPane().add(scrollpane);

setVisible(true);

}//end constructor

}

[3081 byte] By [blackmagea] at [2007-11-27 9:54:26]
# 1
Your table model is hard-coded to always return a string consisting of a space. The method getValueAt is your basic business end, but I see you're hardcoding the other methods returns as well
georgemca at 2007-7-13 0:24:21 > top of Java-index,Java Essentials,Java Programming...
# 2
Your getValueAt() method does nothing but return " ", so that's all you'll ever get out of the table. You should be returning the actual value in the model at that location. See the tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data
hunter9000a at 2007-7-13 0:24:21 > top of Java-index,Java Essentials,Java Programming...
# 3
And, to make life easier for you at this stage, you may want to consider extending DefaultTableModel instead of AbstractTableModel.~
yawmarka at 2007-7-13 0:24:21 > top of Java-index,Java Essentials,Java Programming...
# 4
Still posting in the wrong forum I see...
camickra at 2007-7-13 0:24:21 > top of Java-index,Java Essentials,Java Programming...