Rob Camick wrote:You getValueAt(...) and setValueAt(...) methods make no sense.
According your the column header you have 7 pieces of information. Therefore your swicth statement needs to handle 7 different cases and return the appropriate piece of data. This is:
if column == 0, return name
if column == 1, return code
if column == 2, return dataType
etc...
mark smith wrote:but when i click outside row..... i get a null pointer exception on
i put
to bypass this problem, no sure is the way to go...
why i don't see a checkbox in the boolean field?
any idea?
Brian Cole wrote:
Wouldn't it be easier to just do something like this?
i tried that but i get
if i put
i get
i click go out of the jtable and come back... i get a java.lang.NullPointerException at the same place...
Rob Camick wrote:Well, don't add String data to your TableModel.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Because check boxes only work for Booleans perhaps? You can add Strings to your TableModel all you want, just not for the check box column.
mark smith wrote:
why that return a string... when i specify a Boolean
that should return the correct type for each column...
Brian Cole wrote:
mark smith wrote:
why that return a string... when i specify a Boolean
that should return the correct type for each column...
It returns whatever you tell it to return in the getValueAt(). If you say you will return a Boolean than it expects you to return a Boolean, hence the ClassCastException when you surprise it by returning a String.
If you are expecting the code to somehow convert the the non-Boolean value to a Boolean behind the scenes then you will be disappointed.
the first time the jtable is displayed, attributes is null... so i tried to add this code...
Rob Camick wrote:
the first time the jtable is displayed, attributes is null... so i tried to add this code...
Well, attributes should NEVER be null (it may contain 0 rows).
i added this code
Rob Camick wrote:
i added this code
Well, that is hack fix. You have a fundamental problem with your table. You should design the TableModel such that the attributes ArrayList is NEVER null.
mark smith wrote:
i can put empty value... but i don't find that very logic... create a empty row only to display a jtable... seem weird
i can put empty value... but i don't find that very logic... create a empty row only to display a jtable...