L
Lorenzo
Hi all,
I'm rather inexperienced in Java but I'm in need of defining a subclass
of JTable(N,N) with non-editable underdiagonal elements. I do not know
if it's better to do it by using TableModel or directly JTable, but I
used the latter because it looked easier to me.
The following code gives no errors in NetBeans, but using the newborne
UD_JTable class in MATLAB I get a very nasty error which pretty much
looks like some sort of memory allocation fault.
Here is the code:
import javax.swing.*;
import javax.swing.table.*;
public class UD_JTable extends JTable
{
public UD_JTable(int rows, int cols)
{
super();
}
public boolean isCellEditable( int rowIndex , int columnIndex)
{
if(rowIndex > columnIndex)
{
return false;
}
else
{
return true;
}
}
public static void main(String[] args)
{
}
}
And here is the error
??? Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.table.DefaultTableColumnModel.getColumn(Unknown Source)
at javax.swing.JTable.convertColumnIndexToModel(Unknown Source)
at javax.swing.JTable.setValueAt(Unknown Source)
..
Does anybody have a clue of what's happening???
Thank you ahead
lor
I'm rather inexperienced in Java but I'm in need of defining a subclass
of JTable(N,N) with non-editable underdiagonal elements. I do not know
if it's better to do it by using TableModel or directly JTable, but I
used the latter because it looked easier to me.
The following code gives no errors in NetBeans, but using the newborne
UD_JTable class in MATLAB I get a very nasty error which pretty much
looks like some sort of memory allocation fault.
Here is the code:
import javax.swing.*;
import javax.swing.table.*;
public class UD_JTable extends JTable
{
public UD_JTable(int rows, int cols)
{
super();
}
public boolean isCellEditable( int rowIndex , int columnIndex)
{
if(rowIndex > columnIndex)
{
return false;
}
else
{
return true;
}
}
public static void main(String[] args)
{
}
}
And here is the error
??? Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.table.DefaultTableColumnModel.getColumn(Unknown Source)
at javax.swing.JTable.convertColumnIndexToModel(Unknown Source)
at javax.swing.JTable.setValueAt(Unknown Source)
..
Does anybody have a clue of what's happening???
Thank you ahead
lor