The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

This topic is READ ONLY
import-bot (20211) [Avatar] Offline
#1
[Originally posted by jijohansson]

I'm just starting to program with Swing so I'm trying to run some
of the examples in the Swing Ref book.

I compiled the code for the TreeExample without any problems, but
when I tried to run it I got the messsage:

H:UofACmput301TreeFrame>java TreeFrame
Exception in thread "main" java.lang.ClassCastException
at TreeFrame.<init>(TreeFrame.java:10)
at TreeFrame.main(TreeFrame.java:22)

where the lines causing the problem are:

22: TreeFrame treeFrame1 = new TreeFrame();
10: JTree jTree1 = new JTree(new UIDefaultsTreeModel());

It's just the code that I downloaded from this site.
I'm sure the answer is simple but I don't have the experience to see it.
If you see the problem please let me know.

I have Java 2 running on NT4 with SP5 if that helps.

Thank you,
Jon Johansson.