Posted Wednesday, June 19, 2013 @ 05:13:20
I'm using QuickTable version 3.0 with the current version of swing libraries provided by netbeans 7.3 and I got the following exception setting a column with Type.LONGVARCHAR:
java.lang.ClassCastException: javax.swing.JScrollPane cannot be cast to javax.swing.JTextArea
at quick.dbtable.DBTableColumnModel.setType(DBTableColumnModel.java:354)
at quick.dbtable.DBTableColumnModel.createColumnModel(DBTableColumnModel.java:81)
at quick.dbtable.DBTableModel.createColumnModelFromQuery(DBTableModel.java:2726)
at quick.dbtable.DBTableModel.createColumnModelFromQuery(DBTableModel.java:2609)
The same error rise when the db schema has a field of this type (TEXT, LONGTEXT from mysql or LONGVARCHAR with HSQLDB).
Investingating the source code the class DBTableColumnModel seems bugged. In facts at line 354
setLength((JTextArea)o,tc.getLength());
where o refverence was got with the following code:
dc = new DBTableCellEditor(Column.TEXTAREA_CELL,null, dbTable);
tc.setCellEditor(dc);
o= dc.getComponent();
I checked and o is really a JScrollPane instance not its view, JTextArea.
A patched the code adding a line like:
JTextArea txt = (JTextArea) ((JScrollPane) o).getViewport().getView();
setLength(txt,tc.getLength());
and it looks like working fine.
Now the questions are:
a) was i wrong in setting up the grid or it is effectively a bug ?
b) may this fix produce unwanted side effects in other scenarios ?
Thanks a lot for your support.
--------------------
[pipp8]