Results 1 to 1 of 1
  1. #1
    Luxpsycho is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Question Cast own class to FrameView

    <Dr Nick voice>Hello everybody!</Dr Nick voice>:D

    So, I am using netbeans but I feel this Problem is more specific to Swing/AWT that to the IDE (correct me if wrong).

    I have created a fancy window by clicking all the right buttons without having any idea of the code generated and ended up with:

    Java Code:
    public class MyProgramView extends FrameView { ...
    So that is the class of my main window that opens first.

    In other classes in the same package I often need to reference the instance of MyProgramView because it has tons of methods/variables that matter to the other classes as well.

    Here is what I somehow ended up with:

    Java Code:
    public class PortfoliosTableRenderer extends DefaultTableCellRenderer {
        
        MyProgramView mainFrame = (MyProgramView) MyProgramApp.getApplication().getMainView();
        Language lang = mainFrame.lang;
        
        ....
    Here comes the thing that drives me crazy:
    Yesterday, it woked fine (the table whose renderer I overrid here was displayed correctly and so on...

    This morning, *poof*, the friday0morning effect stroke:

    Java Code:
    java.lang.ClassCastException: org.jdesktop.application.FrameView cannot be cast to myprogram.MyProgramView
    So, summing up, I have my own class that extends another class but for some reason I cannot *anymore* cast from the latter to the former although the object returned by MyProgramApp.getApplication().getMainView() cannot possibly be anything but a MyProgramView....or can it?

    Thanks a lot for your hopefully very helpful help and hope:)

    Luxpsycho

    Editing: not so sure anymore it worked yesterday...
    Still, why does it not work??
    Last edited by Luxpsycho; 07-16-2010 at 11:38 AM. Reason: Edit

Similar Threads

  1. Need Help with Class Cast Exception
    By soxfan714 in forum New To Java
    Replies: 2
    Last Post: 11-03-2011, 05:33 PM
  2. Cannot cast JNLPAppletLauncher to itself
    By kingofearth in forum Java Applets
    Replies: 0
    Last Post: 01-19-2010, 08:37 PM
  3. class cast exception
    By venkatallu in forum New To Java
    Replies: 2
    Last Post: 09-02-2008, 10:50 PM
  4. Replies: 1
    Last Post: 08-02-2007, 05:07 PM
  5. How can I cast Object as an int
    By romina in forum New To Java
    Replies: 1
    Last Post: 07-18-2007, 12:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •