This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Custom ComboBox with icon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Custom ComboBox with icon" Watch "Custom ComboBox with icon" New topic

Custom ComboBox with icon

Kah Fai Tan

Joined: Jun 16, 2007
Posts: 3

Above is my coding, when I run the file it show me

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String
at Lion_Dance.Judge$ComboBoxRenderer.getListCellRendererComponent(

I am not sure where is wrong. Please help
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2454
First you need to learn how to post a proper demo program.

1) We don't have time to read through 400 llines of code. So you need to learn how to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

2) The code you posted doesn't compile. Most of use don't use an IDE to create a GUI so we don't have access to the org.desktop.layout.GroupLayout class. So if you want us to run your code then you need to post executable code, which is why you create a SSCCE.

Finally, the error messages tells you the problem. You get a ClassCastException. It should also tell you the line that is causing the problem. It found a String, but your code is expecting something else. So either your data is wrong or the code is wrong.
I agree. Here's the link:
subject: Custom ComboBox with icon
It's not a secret anymore!