aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How do I call removeColumn by name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do I call removeColumn by name?" Watch "How do I call removeColumn by name?" New topic
Author

How do I call removeColumn by name?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 601

How do I call removeColumn by name?
I haven't manifest all the columns in my query.
In my Customer1, only customer codes, last names , first names , mobile phone numbers and net sales
for that customer are queried.
The BeanTableModel listed out all attributes in an unpredictable way, sometimes lastname is in column 3 and sometimes it is in column 6 etc
I also tried these


I refer "residence" as the name of attribute in the bean.

which results in
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Identifier not found
at javax.swing.table.DefaultTableColumnModel.getColumnIndex(DefaultTableColumnModel.java:282)
Thanks
Jack

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
The BeanTableModel listed out all attributes in an unpredictable way


Yes, it uses reflection and reflection does not guarantee the order in which the fields are returned.

sometimes lastname is in column 3 and sometimes it is in column 6 etc


The order should be consistent. That is once you create a Bean the field names should be returned in the same order every time the code is executed. However, that doesn't really help you with your problem. So you need to read the blog entry. It suggests a way that you can resort the TableColumns so the data is displayed in the order you wish to see the data. You will need to follow the link to another blog entry.

How do I call removeColumn by name?


You use the "column name", not the property name. a TableColumnModel knows nothing about where the data came from, so why would it know the data came from a bean with the property name that you specified?
 
 
subject: How do I call removeColumn by name?