Results 1 to 9 of 9
  1. #1
    arulmozs is offline Member
    Join Date
    Oct 2009
    Posts
    7
    Rep Power
    0

    Default Menu Type cast Exception

    exception

    java.lang.ClassCastException: org.jvnet.lafwidget.menu.MenuSearchWidget$SearchPa nel cannot be cast to javax.swing.JMenuItem
    at org.digitalmonks.automenu.view.automenu.ABarMenuVi ew.tranverseView(ABarMenuView.java:40)
    at org.digitalmonks.automenu.view.automenu.ABarMenuVi ew.<init>(ABarMenuView.java:25)
    at org.digitalmonks.automenu.AutoMenu.<init>(AutoMenu .java:35)
    at org.digitalmonks.automenu.ABarMenu.<init>(ABarMenu .java:10)
    at Amain.ExecuteMainFrame.login(ExecuteMainFrame.java :228)



    source code

    in that line we use



    ABarMenu abarmenu ;
    String path="";
    if (Main.accounttype.equalsIgnoreCase("Admin")) {
    path = "\\xmlpath\\barmenu.xml";
    } else if (Main.accounttype.equalsIgnoreCase("Demo")) {
    path = "\\xmlpath\\demo.xml";
    } else if (Main.accounttype.equalsIgnoreCase("User")) {
    path = "\\xmlpath\\demo.xml";
    } else if (Main.accounttype.equalsIgnoreCase("Work")) {
    path = path + "\\work.xml";
    } else if (Main.accounttype.equalsIgnoreCase("Master")) {
    path = "\\xmlpath\\demo.xml";
    }
    log.info(path);

    abarmenu = new ABarMenu(path, this, actionTarget);



    pls tell what can i change in that coding

  2. #2
    moorthi is offline Member
    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Default

    ABarMenuVi ew.tranverseView(ABarMenuView.java:40)
    Exception in ABarMenuView method tranverseView

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    The code you posted has nothing to do with the problem the problem is on ABarMenuView line 40.

  4. #4
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    java.lang.ClassCastException:
    org.jvnet.lafwidget.menu.MenuSearchWidget$SearchPa nel
    cannot be cast to javax.swing.JMenuItem at
    ... .view.automenu.ABarMenuView.tranverseView(ABarMenu View.java:40


    While the problem is detected in transverseView() line 40,
    the erroneous code is elsewhere. TransverseView has looked
    at some field f in some menu structure ms and found a value that
    it expects to be a JMenuItem. However, when the program
    created ms it inserted into f a value of type MenuSearchWidget.SearchPanel,
    which is not a subclass of JMenuItem.

    The code to look at is the code that creates the menu structure,
    focusing on the place where it inserts a MenuSearchWidget.SearchPanel
    into the structure.

    One possibility--however remote--is that org.jvnet.lafwidget objects are
    not suitable for use with org.digitalmonks.automenu.
    Last edited by zweibieren; 10-29-2009 at 02:03 PM. Reason: extend

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by zweibieren View Post
    java.lang.ClassCastException: org.jvnet.lafwidget.menu.MenuSearchWidget$SearchPa nel
    cannot be cast to javax.swing.JMenuItem at
    ... .view.automenu.ABarMenuView.tranverseView(ABarMenu View.java:40


    While the problem is detected in transverseView() line 40,
    the erroneous code is elsewhere. TransverseView has looked
    at some field f in some menu structure ms and found a value that
    it expects to be a JMenuItem. However, when the program
    created ms it inserted into f a value of type MenuSearchWidget.SearchPanel,
    which is not a subclass of JMenuItem.
    Assuming that the expectation of f being a JMenuItem is correct.

  6. #6
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    The full code was posted in another thread, but I am continuing here.

    The full code does not refer to MenuSearchWidget, so I imagine that
    that object is incorporated via one of the xml files listed in the code above:
    \\xmlpath\\barmenu.xml
    \\xmlpath\\demo.xml
    \\xmlpath\\work.xml
    Probably the first of these.

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    So the xml files are being used to create the menu items?
    Would have been nice if the OP had mentioned that.

  8. #8
    arulmozs is offline Member
    Join Date
    Oct 2009
    Posts
    7
    Rep Power
    0

    Default Create JMenubar Using Database

    Pls any one help how to create jmenu bar using database pls help me soon....

  9. #9
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    Have you looked at \\xmlpath\\barmenu.xml as suggested above?

Similar Threads

  1. Need Help with Class Cast Exception
    By soxfan714 in forum New To Java
    Replies: 2
    Last Post: 11-03-2011, 04:33 PM
  2. [SOLVED] Cast string type to int type
    By GilaMonster in forum New To Java
    Replies: 9
    Last Post: 09-17-2008, 10:43 AM
  3. Help determing NamingEnumeration type/cast
    By BlankMan in forum Eclipse
    Replies: 1
    Last Post: 09-05-2008, 07:50 AM
  4. class cast exception
    By venkatallu in forum New To Java
    Replies: 2
    Last Post: 09-02-2008, 09:50 PM
  5. How to cast an Object into a specific type (Integer/String) at runtime
    By mailtogagan@gmail.com in forum Advanced Java
    Replies: 2
    Last Post: 12-03-2007, 01:04 PM

Posting Permissions

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