I am currently a consultor in a Java Swing project that uses JGoodies 1.2.1. My current job is writing GUI dialogues. A few weeks ago, a colleague of us wrote a code generators that produce all dialogues that are not very complicated. So, for simple dialogues, we should use the generator.
When comparing the generated code with my own dialogue code, I get a class cast exception that I do not understand. Perhaps, you can help me.
The code uses so-called Data Transfer Objects (DTOs). I have a method in the generated code that is called loadObjects()
, where I get the exception.
In the attached code, you see that for loop line exists two times, one being commented out. In this case, I get the eclipse (static syntactical) error "Type mismatch: Cannot convert from element type CalendarMacrosDTO
". It is a clear error, so I comment the now uncommented line and introduce the commented line as code; there is no statical error now.
When I run the code, I get an exception at the now uncommented line for (final CalendarMacrosDTO dto : list)
Exception in thread "main" java.lang.ClassCastException: net.atos.roman.tmtbl.client.gui.wizard.calendar.macros.model.CalendarMacrosDTOAdapter cannot be cast to net.atos.roman.tmtbl.liaison.calendar.macros.CalendarMacrosDTO
Obviously, I got the wires crossed. :-) Can you explain what I am doing wrong here?
Thanks in advance!