Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: awt cardlayout help

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    My Mood
    Nerdy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question awt cardlayout help

    there is no good tourtals online for this here is my code + errors
     
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
            CardLayout card = (CardLayout) Start_menue.getLayout();
            card.show(Start_menue, "Game_SinglePlayer");
        }


    run:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: org.jdesktop.layout.GroupLayout cannot be cast to java.awt.CardLayout
    at NewJFrame.jButton5ActionPerformed(NewJFrame.java:3 08)
    at NewJFrame.access$300(NewJFrame.java:13)
    at NewJFrame$4.actionPerformed(NewJFrame.java:100)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.jav a:6505)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
    at java.awt.Component.processEvent(Component.java:627 0)
    at java.awt.Container.processEvent(Container.java:222 9)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4861)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
    at java.awt.Component.dispatchEvent(Component.java:46 87)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719 )
    at java.awt.Component.dispatchEvent(Component.java:46 87)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:713)
    at java.awt.EventQueue.access$000(EventQueue.java:104 )
    at java.awt.EventQueue$3.run(EventQueue.java:672)
    at java.awt.EventQueue$3.run(EventQueue.java:670)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:686)
    at java.awt.EventQueue$4.run(EventQueue.java:684)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 683)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:244)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:97)
    BUILD SUCCESSFUL (total time: 7 seconds)


    happens after i click the button to change jframes from the jpannle

    also im yousing netbeens 7.2.1 IDE
    Last edited by op117; August 28th, 2012 at 07:43 PM. Reason: more info


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: awt cardlayout help

    java.lang.ClassCastException: org.jdesktop.layout.GroupLayout cannot be cast to java.awt.CardLayout
    Why are you trying to cast what is returned by the getLayout() method to a CardLayout object?
    The method is returning a GroupLayout object.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: awt cardlayout help

    Quote Originally Posted by op117 View Post
    there is no good tourtals online for this
    I'm not sure where or how you looked, but there's a great tutorial right here: The CardLayout. In fact if you Google "CardLayout Tutorial" it's the first hit.

  4. #4
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    My Mood
    Nerdy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: awt cardlayout help

    Quote Originally Posted by curmudgeon View Post
    I'm not sure where or how you looked, but there's a great tutorial right here: The CardLayout. In fact if you Google "CardLayout Tutorial" it's the first hit.
    for netbeans it's different due to the code generation ect. cant find any thing on this for 7.2 version that is were im having trouble.

  5. #5
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    My Mood
    Nerdy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: awt cardlayout help

    this is what im converting to card layout..JavaApplication2.src.zip in a .zip file site up loader wood not let it be any outer way...

    there is all the .java files note no logic is done trying to get GUI working first and the logic code is easy.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: awt cardlayout help

    Please post the code with the problems here on the forum.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Problem with CardLayout
    By FireStorm in forum AWT / Java Swing
    Replies: 1
    Last Post: March 30th, 2012, 03:45 PM
  2. CardLayout wont go to the next card
    By pottsiex5 in forum AWT / Java Swing
    Replies: 2
    Last Post: November 25th, 2011, 04:04 PM
  3. How to use CardLAyout without using applets???
    By divyarattan in forum AWT / Java Swing
    Replies: 4
    Last Post: August 9th, 2011, 11:19 AM
  4. Cardlayout Question
    By wagb278 in forum AWT / Java Swing
    Replies: 2
    Last Post: April 10th, 2011, 03:23 PM
  5. Cardlayout help
    By phantomswordsmen in forum AWT / Java Swing
    Replies: 1
    Last Post: December 22nd, 2010, 02:36 PM