data3 is Object[][] data3 = { {1,1,1},
{1,1,1},
{1,1,1}
};
Oliver Wong wrote:
> <> wrote in message
> news: ps.com...
> > Dear Java experts,
> >
> > I have a JTable problem here.
> > Problem description: I have to display a default table(3X3) when the
> > application launches for the first time. Then user should able to
> > modify the table and my application should able to read the changed
> > values in this table. Please have a look at the below code.
> >
> > Table3.addActionListener(new ActionListener(){
> > public void actionPerformed(ActionEvent e){
> >
> > for(int i = 0; i < 3; i++){
> > for(int j = 0; j < 3; j++){
> > try{
> > t3[i][j] =
> > ((Integer)data3[i][j]).intValue();
> > }catch(ClassCastException cce){}
> > }
> > }
> > table3.getModel().addTableModelListener(new
> > TableModelListener(){
> > public void tableChanged(TableModelEvent e) {
> > int row = e.getFirstRow();
> > int column = e.getColumn();
> > TableModel model = (TableModel)e.getSource();
> > String columnName = model.getColumnName(column);
> > Object data3 = model.getValueAt(row, column);
> > t3[row][column] = new
> > Integer((String)data3).intValue();
> > }
> > });
> > }
> > });
> >
> > here table3 is a JTable
> > Table3 is the radio button used to select that matrix
> > data3 is an Object[][] with column names for JTable
> > t3 is the default matrix used and modified by the user.
> >
> > When I use this code, my application throwing ClassCastException
> > because of converting data3 to t3. Can any body help me?
> >
>
> The data3 on the 8th line of code that you posted never gets declared
> anywhere. Please post an SSCCE: http://mindprod.com/jgloss/sscce.html
>
> - Oliver