Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes JDialog with ClassCastException ?!??! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog with ClassCastException ?!??!" Watch "JDialog with ClassCastException ?!??!" New topic

JDialog with ClassCastException ?!??!

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755

I want to invoke a jdialog and I'm using this line of code:

Component c = SwingUtilities.getRoot((Component)e.getSource());
JDialog subDialog = (JDialog)c;

It works GREAT in the entire project;

but for some reason, in diff class I get this message:
at CustomizeAgent.actionPerformed(
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)...

WHY??? any idea how to correct it?
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
the root of e.getSource() is not a JDialog
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755


right!!! thanks - I corrected it and it works.

I agree. Here's the link:
subject: JDialog with ClassCastException ?!??!
It's not a secret anymore!