0

For customizing uitable there are a lot of good tips on http://undocumentedmatlab.com/. So I was trying to realize individual format for every cell of a table, as described in chapter 4.1.1 in undocumentedmatlab author's book.

Unfortunately I do not understand the Java-Matlab connection very well, so I was wondering whether someone already did this and that example and can give me some tips.

First I started at the very beginning and checked my java version and installed JDK:

version -java

Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode

!javac -version

javac 1.6.0_45

Second I added the enviroment variable JAVA_HOME and edited PATH.

Third I downloaded the custom CellEditor Class, provided by undocumentedmatlab.com: LookupFieldCellEditor.zip, which contains the .java and the .class file. http://bit.ly/aiHumG

So now I am thinking I did everything necessary to start fusing Matlab and Java to costumize my uitable. For the start I just copied the main idea from the book:

mtable = uitable;
set(mtable,'ColumnEditable', [true, true]);
fieldsHashtable = java.util.Hashtable;
fieldsHashtable.put('Meat',{'steak','veal'}, 1.99);
fieldsHashtable.put('Vegetables',{'Salad','Lettuce'} , 2.50);
jtable.getColumnModel.getColumn(1).setCellEditor(ed);

Surprise, this is not working. The error message:

No method 'put' with matching signature found for class 'java.util.Hashtable'.

I already searched a while and tried different stuff to get it work (like using keys for the hashtable, trying differnt types of inputs, etc.), but I think I am missing something general, caused by the lack of understanding.

Thank you in anticipation!

1 Answers1

0

I think it is usualy

put(key, value)

you are calling it

put(key, something, value)

consider using other data structure.

put({key,something},value);
put(key,{something,value});

or use 2 tables.

Steffen
  • 2,381
  • 4
  • 20
  • 33
  • oh wow that was easy. Thanks. So can I ask another queastion? It is said that I shall put a generated class file (i.e. the LookupFieldCelleditor.class) in my Java classpath. How do I do this? – Tanja Lange Oct 30 '14 at 15:12
  • selfanswered: javaaddpath (foldername containing the class file). Thank you again, you made my day. – Tanja Lange Oct 30 '14 at 15:19